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

How To Make It So A Person Doesn't Spam The onTouched Event?

Asked by 8 years ago

Here is what I did, but it still spams the onTouched event.

local debounce = false 

function onTouched(hit) 
    if debounce == false then 
        debounce = true 
        script.Parent.Sound:Play()
        wait(4)
        debounce = false 
        else debounce = false 
    end 
end

script.Parent.Touched:connect(onTouched) 

Thank you for your time! Your awesome!

0
Remove line 9. Once you make it false with the else statement it is free to go back to going to use again. M39a9am3R 3210 — 8y
0
Thank you! GatitosMansion 187 — 8y

Answer this question