No. Lua supports goto only from 5.2 beta versions and on; ROBLOX is stable 5.1.
It is a general consensus (though this is debated) that gotos are rarely what you want to use to solve a problem.
break (not "continue" -- Lua doesn't have continue -- mistake -- thank you TaslemGuy) act as a form of limited jumping.
Functions are a very powerful way to define routines.
If you specify a particular problem, we could describe a good solution (that doesn't need goto)
First, I would definitely simplify the second loop you have:
while game.Players.NumPlayers < 2 do
wait()
end
I'm not exactly sure what you want to do. I don't see any particular point where you would want to act.
But speaking very generally, this is an architecture that might work for you:
local modes = {}
function modes.intermission()
for i = 1, 30 do
wait(1)
if game.Players.NumPlayers < 2 then
return "waitForPlayers"
break
end
end
return "playGame"
end
function modes.waitForPlayers()
while game.Players.NumPlayers < 2 do
wait()
end
return "intermission"
end
local mode = "intermission"
while true do
mode = modes[mode]()
wait()
end
Clever breaks and ifs would also work, but could get to be a mess with a larger script.
2 comments
I edited, please look
One note: Lua does not have a
continuekeyword.