So i was making a admin gui for a game that im working on and i wanted to create some templates for buttons.
I made something similar in the past but i lost it since i didnt upload it to roblox.
But for some reason everything looks good and the buttons do its just what the script needs to repeat is the problem.
local button = script.Parent.Parent
local enabled = false
button.MouseButton1Down:Connect(function()
print("Checking If Its Enabled")
if enabled == false then
enabled = true
print("Not Enabled")
else
enabled = false
print("Enabled")
end
end)
while enabled == 2 do
--Put your event you want to repeat
print("Repeating")
wait(1)
end
The while loop is like an if statement. If the following statement is true, then it starts repeating.
You should move the while loop to inside the if statement. I’m on mobile so I cant put a script down so I think you should be able to figure it out yourself.
local button = script.Parent.Parent
local enabled = false
while true do
if enabled = true then
--repeat
end
wait(0.025)
end
button.MouseButton1Down:Connect(function()
if enabled = false then
enabled = true
else
enabled = false
end
end)