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

Issue with "if" & "else" running after "else" if "if" is true?

Asked by
Hizar7 102
4 years ago

So in my script, it runs quite a long script when it activates, but I wanted to add a

local item = math.random (1,300)

if item == 50 then

billboard = true

else

rest of script

but if it rolls 50, how do I make it run "rest of script" after the "else" without duplicating it all before the "else" ?

0
This question doesn't really make any sense. The whole point of having if-else is so that when it rolls 50, the "rest of script" in the else block *doesn't* run. Otherwise you wouldn't have an else block. EmilyBendsSpace 1025 — 4y

2 answers

Log in to vote
1
Answered by
Farsalis 369 Moderation Voter
4 years ago
Edited 4 years ago

A quick little monkey patch to this is, throw your code into a function, then just have each statement call that function. Don't know if that was really what you were looking for, but hope that might've helped.

Ad
Log in to vote
0
Answered by 4 years ago

Unfortunately, there is no way to do what you have requested. You are going to have to re write the if statement OR don't add the else at all.

Here's an example:

local item = math.random (1,300)

if item == 50 then

billboard = true
--rest of script -- so since u wanna run everything under the else just don't add an else or just copy paste the rest of script to here
else

--rest of script
end

Good luck

0
wish i could've accepted both answers, either way ill have to double the code so they both basically answered it Hizar7 102 — 4y

Answer this question