So basically when I click the button the light.Enabled = false and when I click the button again the light.Enabled = false. I am trying to figure out how to add a cooldown to the script so players won’t be able to spam the button.
Here is the script:
local button = game.Workspace.LampModel.Button.ClickDetector
local light = game.Workspace.LampModel.Lamp.PointLight
DEBOUNCE = false
button.MouseClick:Connect(function()
if light.Enabled == false and not DEBOUNCE then
light.Enabled = true
else
light.Enabled = false
end
end)
local button = game.Workspace.LampModel.Button.ClickDetector
local light = game.Workspace.LampModel.Lamp.PointLight
DEBOUNCE = false
amount = 2
button.MouseClick:Connect(function()
if not DEBOUNCE then
DEBOUNCE = true
light.Enabled = not light.Enabled
task.wait(amount)
DEBOUNCE = false
end
end)