#My script starts lying to me after a few seconds
1 messages · Page 1 of 1 (latest)
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local spawnThorne_RE = game.ReplicatedStorage.Brickmin:WaitForChild("spawnThorne")
local getMouseDotPos_RE = game.StarterPlayer.StarterPlayerScripts:WaitForChild("getMouseDotPos")
local hasCursor = false
local spawnPos;
getMouseDotPos_RE.Event:Connect(function(mouseDotPos)
spawnPos = mouseDotPos
end)
userInput.InputBegan:Connect(function(input, gameprocessed)
if gameprocessed then return end
for i,v in pairs(char:GetDescendants()) do
if v.Name == "Cursor" then
hasCursor = true
else
hasCursor = false
end
end
print(hasCursor)
if hasCursor and input.KeyCode == Enum.KeyCode.Four then
--print(player.Name .. " pressed 4")
spawnThorne_RE:FireServer(spawnPos)
--print(`{player.Name} wants to spawn a Thorn.`)
end
end)```
Once the player gets a cursor, the hasCursor becomes true. However, it should stay true indefinitely, since as of now, the player has no way of getting the rid of the cursor unless they reset.
** You are now Level 9! **
Liar liar pants on fire.
Your loop isn't actually checking if the character has a cursor, it's checking if the last descendant in the list is the cursor
Here's a fixed version
local hasCursor = false
for _, descendant in character:GetDescendants() do
if descendant.Name == "Cursor" then
hasCursor = true
break
end
end
It seems I'll need to familiarize myself with break then. Thx
yo uh, I have a question
Speak up.
mty text wasn't loading
how do i add a box around text like bob did
this is how ya do it
You use `
This works but once the player resets and has no more cursor script, the hasCursor is still set to true. Do you know how to fix this?
nvm figured out i could js do this using tables
and getting the amount of objects in a table to use as a psuedo boolean
nvm it dont work lmfao