Hello everyone, I'm trying to make it so that my script doesn't run all at once and wait() is not what I want. When I click, all of the script starts, is there any way to stop it once the variable toggle has changed?
local button = script.Parent local function click() local toggle = 1 if toggle == 1 then button.Font = Enum.Font.Arcade toggle = 2 end if toggle == 2 then button.Font = Enum.Font.Highway toggle = 3 end if toggle == 3 then button.Font = Enum.Font.Fantasy toggle = 4 end if toggle == 4 then button.Font = Enum.Font.GothamBold toggle = 5 end if toggle == 5 then button.Font = Enum.Font.SourceSans toggle = 1 end end button.MouseButton1Down:Connect(click)
Thanks, any help would be appreciated
I know you said that you didnĀ“t want any wait(). However, I am not sure that you have considered this. You could use a repeat until loop combined with wait() to stop your script from running until a certain condition is met.
local button = script.Parent local function click() local toggle = 1 repeat wait() if toggle == 1 then button.Font = Enum.Font.Arcade toggle = 2 end if toggle == 2 then button.Font = Enum.Font.Highway toggle = 3 end if toggle == 3 then button.Font = Enum.Font.Fantasy toggle = 4 end if toggle == 4 then button.Font = Enum.Font.GothamBold toggle = 5 end if toggle == 5 then button.Font = Enum.Font.SourceSans toggle = 1 end until --statement is met end button.MouseButton1Down:Connect(click)
I could've just used elseif instead of multiple if statements.