I have the following script inside a button:
local click = script.Parent.ClickDetector
module = require(script.Parent.Parent.functions)
local debounce = false
local blox = workspace.iBlox
click.MouseClick:connect(function()
if not debounce then
debounce = true
module.StartUp(blox)
wait(5)
debounce = false
end
end)
The StartUp() function is in a module:
function module.StartUp(blox)
local on = blox.TurnedOn
local gui = blox.Screen.StartUp
local rotate = gui.Frame.ImageLabel
local y = 1
local button = blox.onoff
rotate.Rotation = 0
if on.Value == false then
on.Value = true
button.Material = Enum.Material.Neon
gui.Enabled = true
wait(2)
rotate.Visible = true
y = 1
while y < 200 do
y = y + 1
rotate.Rotation = y
if on.Value == false then
break
end
wait()
end
else
button.Material = Enum.Material.SmoothPlastic
on.Value = false
gui.Enabled = false
rotate.Visible = false
end
end
I want it to debounce so the button wont do anything until 5 seconds pass after it's been pressed but it will go over the whole function and more seconds pass, is there a way I could work around this?
