Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make it that the script stops at a certain place? (ANSWERED)

Asked by 5 years ago
Edited 5 years ago

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?

01local button = script.Parent
02 
03local function click()
04    local toggle = 1
05    if toggle == 1 then
06        button.Font = Enum.Font.Arcade
07        toggle = 2
08    end
09    if toggle == 2 then
10        button.Font = Enum.Font.Highway
11        toggle = 3
12    end
13    if toggle == 3 then
14        button.Font = Enum.Font.Fantasy
15        toggle = 4
View all 27 lines...

Thanks, any help would be appreciated

2 answers

Log in to vote
0
Answered by 5 years ago

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.

01local button = script.Parent
02 
03local function click()
04    local toggle = 1
05 
06    repeat wait()
07        if toggle == 1 then
08                button.Font = Enum.Font.Arcade
09                toggle = 2
10        end
11 
12        if toggle == 2 then
13                button.Font = Enum.Font.Highway
14            toggle = 3
15        end
View all 34 lines...
0
Please remember to accept my answer if you find it useful. AndriusTheGreat 140 — 5y
0
Wait guys, sorry, I'm just stupid, I could've just used elseif, sorry. killerninja81 30 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

I could've just used elseif instead of multiple if statements.

Answer this question