I made a local script to detect how many players are in the game, then put that on a text label. When I run it, it gives me “Game script timeout” on line 13. I do not understand. My script:
playerCount = game.Players.NumPlayers if game.Players.NumPlayers >= 2 then script.Parent.Text = game.Players.NumPlayers.." Players" else script.Parent.Text = game.Players.NumPlayers.." Player" end while true do if game.Players.NumPlayers >= 2 then script.Parent.Text = game.Players.NumPlayers.." Players" else script.Parent.Text = game.Players.NumPlayers.." Player" end end
there has to be a wait inside of any while true loop. Not doing so results in the timeout or roblox crashing. While true runs the code 30 times per second if not specified otherwise.
playerCount = game.Players.NumPlayers if game.Players.NumPlayers >= 2 then script.Parent.Text = game.Players.NumPlayers.." Players" else script.Parent.Text = game.Players.NumPlayers.." Player" end while true do if game.Players.NumPlayers >= 2 then script.Parent.Text = game.Players.NumPlayers.." Players" else script.Parent.Text = game.Players.NumPlayers.." Player" end wait(0.1) end