Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script executes alot debounce wont work?

i have this code but it executes alot without a cooldown?

db = true

if not db == false then

script.Parent.Parent.Name = "hi"
wait (2)
script.Parent.Parent.Name = "bye"

print ("executed")

end
db = true

1 comment

0

I don't understand why you have added a debounce here?

1 answer

✓ Accepted answer

I can only guess the reason in which you wanted to use a debounce was because you had a 'Touched' event previously, so to help me to understand I also added a touch event which you may change later if you wish.

Code:

local debounce = false

script.Parent.Touched:Connect(function()
	if not debounce then
		debounce = true
		script.Parent.Parent.Name = "Hi"
		wait(2)
		script.Parent.Parent.Name = "Bye"
		print("Executed")
		debounce = false
	end
end)

You just slightly had your debounces mixed up, but that seems to have solved the problem. Please accept my answer if it works, thanks.

1 comment

0

yaya thx

This discussion is preserved as it was. New answers, comments, and votes are closed.