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 a round script?

I was wondering how to make a round script that NEVER Ends, so The game can continue.

2 answers

✓ Accepted answer

There are a few ways to do this. The first method is using a while loop.

while true do
    PlayRound()
end

This will constantly execute any code in the PlayRound function (which will need to be defined above the while loop), and for your case, the code to play your game in rounds will go inside. Another method is an infinite for loop:

for i = 1, math.huge do
    PlayRound()
end

Another would be the repeat-until loop:

repeat
    PlayRound()
until false

One other option you have is a recursive call to your round function.

function PlayRound()
    -- code in here to play the round

    PlayRound() -- start the next round
end

PlayRound() -- start the first round

You'll notice above that the PlayRound function actually calls itself. This will happen infinitely unless (like all other methods) there is an error in your script.

Which method you pick is up to you. The while loop is the easiest to understand, while the recursive function (the last example) would be highly beneficial to learn. It's your call, though.

1 comment

0

Thanks!

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