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 5 years ago

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

01db = true
02 
03if not db == false then
04 
05script.Parent.Parent.Name = "hi"
06wait (2)
07script.Parent.Parent.Name = "bye"
08 
09print ("executed")
10 
11end
12db = true
0
I don't understand why you have added a debounce here? RyanTheLion911 195 — 5y

1 answer

Log in to vote
0
Answered by 5 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:

01local debounce = false
02 
03script.Parent.Touched:Connect(function()
04    if not debounce then
05        debounce = true
06        script.Parent.Parent.Name = "Hi"
07        wait(2)
08        script.Parent.Parent.Name = "Bye"
09        print("Executed")
10        debounce = false
11    end
12end)

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 — 5y
Ad

Answer this question