I have the function in the module script:
local 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 < 1000 do
y = y + 1
rotate.Rotation = y
if on.Value == false then
break
end
wait(.01)
end
else
button.Material = Enum.Material.SmoothPlastic
on.Value = false
gui.Enabled = false
rotate.Visible = false
end
end
return module
When I click the button that triggers it once it works just fine but if I spam it the while function mixes up with the other while functions that haven't been stopped in the background thus accelerating the ImageLabel's rotation. How can I fix this?

5 comments
modulescript:Destroy()
wouldnt this also destroy the script inside i mean i want to use this function again
Your saying it bugs out when you spam click it. Make it so when you click it once, you can't click it anymore. Or, add a cooldown
^
thank you