Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script executes alot debounce wont work?

Asked by 4 years ago

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

0
I don't understand why you have added a debounce here? RyanTheLion911 195 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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.

0
yaya thx fistter1 88 — 4y
Ad

Answer this question