while
loops must contain some sort of delay, otherwise they will crash the server. Usually this delay is the wait()
function.
Your loop contains several of these functions, but notice that they're all inside of your first if
statement! This means that if your if
statement is false, your script will never wait, and thus crash.
Just add a small delay every time it loops, no matter the outcome of the if
statement.
03 | if game.Players.NumPlayers > 1 then |
04 | h.Text = "Deciding what game to play" |
06 | ranGame = math.random( 1 , #minigames) |
07 | gameChosen = minigames [ ranGame ] |
08 | h.Text = "Minigame chosen: " .. gameChosen.Name |
10 | gameChosenClone = gameChosen:Clone() |
11 | gameChosenClone.Parent = game.Workspace |
14 | spawns = gameChosenClone.Spawns:GetChildren() |
15 | for i,v in pairs (game.Players:GetPlayers()) do |
17 | check = game.Workspace:FindFirstChild(name) |
19 | checkHumanoid = check:FindFirstChild( "Humanoid" ) |
21 | v.Character:MoveTo(spawns [ i ] .Position) |
26 | h.Text = "Game begins in: " .. i |
29 | if gameChosenClone.Name = = "DisappearingPlates" then |
32 | for i = timeTillGameEnds, 1 , - 1 do |
33 | h.Text = "Time Left: " .. i |
38 | h.Text = "There needs to be more than 1 player to start" |