Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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" ?

1 comment

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.

2 answers

✓ Accepted answer

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.

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

1 comment

0

wish i could've accepted both answers, either way ill have to double the code so they both basically answered it

This discussion is preserved as it was. New answers, comments, and votes are closed.