I'm trying to make a loop that prints "aa" when the gui is toggled and when it's not it will print "a" once, but even after I turn off toggle it keeps on going
function aa(toggled)
if toggled then
repeat wait()
print("aa")
until not toggled
else
print("a")
return
end
end

5 comments
Will do!
:)
It still keeps on printing, also I've wanted to make the loop constantly fire a RemoteEvent for an autoclicker in my game, but it keeps on going when I click the button to turn it off, do you know what I should do?
Fixed it! Now the code definitely works!
Did another edit, because I realised you wanted it to only print 'a' once instead of until the button is pressed again. Now the script should print "aa" constantly until you click the button, after which it will print "a" once. Pressing the button again will keep toggling on and off :)