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
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
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.
yaya thx
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
I don't understand why you have added a debounce here?