local debounce = false function onTouch(hit) if debounce == true then return end debounce = true local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then local message = Instance.new("Hint",game.Workspace) for i=10,0,-1 do message.Text = i.. wait(1) debounce = false end end end script.Parent.Touched:connect(onTouch) message:remove() The script keeps repeating from 10 every time the brick is touched. What's the issue with it?
Simple,you set the individual pair "I to 10,0,-1 all you have to do is change the i pairs assigned number to a lower number and the denounce to true maybe then it won't have to repeat the script.
The problem is that you are disabling the debounce too early. Instead of disabling it inside the for loop, disable it afterwards. You also should destroy the message inside the touched handler. It doesn't exist outside the scope of the touch handler:
local debounce = false function onTouch(hit) if debounce then return end debounce = true local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then local message = Instance.new("Hint",game.Workspace) for i=10,0,-1 do message.Text = i --Edit: Remove the ellipsis from this line wait(1) end debounce = false message:Destroy() end end script.Parent.Touched:connect(onTouch)
This will prevent the function from executing again until the countdown is finished.
Edit: Removed an ellipsis on line 10