I am trying to make it so when a player clicks the On button it gives then 1 click every 0.5 seconds. But if they click the off button, it stops.
Here's my code: When I test this, it works when I press On, but it doesn't stop when I press off.
local GUI = script.Parent
local onButton = GUI.OnButton
local offButton = GUI.OffButton
local plr = game.Players.LocalPlayer
while onButton.MouseButton1Click do
while wait() do
local plrClicks = plr.leaderstats.Clicks
plrClicks.Value = plrClicks.Value + 1
if offButton.MouseButton1Click then
break
else
--contine loop?
end
end
end
If you have any idea how to fix this, please help!

2 comments
You haven't connected any function to offButton.MouseButton1Click, it isn't a bool, it's an event.
What do I do to fix that?