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

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

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

2 comments

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.

0

bro this is easy you have 4k rep what are you DOING

1 answer

✓ Accepted answer
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

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