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

How to make my script choose any random line of code in a while loop?

Asked by 4 years ago

I want to make the script choose any random line of code in the while loop

while true do
    print ("Choice1")
    print ("Choice2")
    print ("Choice3")
    print ("Choice4")
end
0
The only way I can possibly see this is an array of code lines stored as String in conjunction with loadstring, yet this function is a v e r y bad choice. An alternative option is to Enable a random script. Ziffixture 6913 — 4y
0
bro this is easy you have 4k rep what are you DOING Andy_Wirus 72 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
creativlyNamedVariable = math.random(1, 4)
if creativlyNamedVariable == 1 then
    --code
elseif creativlyNamedVariable == 2 then
    --code
elseif creativlyNamedVariable == 3 then
    --code
elseif creativlyNamedVariable == 4 then
    --code
end
Ad

Answer this question