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

Where and can this local debounce script work?

Asked by 5 years ago
Edited 5 years ago

I made a button game that uses debounce as a cooldown before button is usable, but I also want the button to cancel the cooldown whenever this script is in workspace and I inserted this script onto workspace. However, I do not know to advanced of scripting so I need help if I need corrections on my script.

Button = script.Parent
if local debounce == false then
    wait(10)
    local debounce = true
    Button.Material = ("Neon")
end

P.S. This is a local script I put in

1 answer

Log in to vote
1
Answered by 5 years ago

When you use "local" before something, it turns it into a variable. So, you need to define your debounce variable and then after that just say "debounce" without the "local" part. An example of your code with some changes:

local button = script.Parent
local debounce = true
if debounce == false then
    wait(10)
    debounce = true
    button.Material = Enum.Material.Neon
end

Hope this helps! (Also, if you use a LocalScript, the changes made by it will only affect the player who fires the function. Use a regular script if you want the changes to be seen across the whole server.)

0
Didn't work User#30241 0 — 5y
0
What's your way of activating the button? QuantumPlasmic 84 — 5y
Ad

Answer this question