Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Getting NumPlayers Crashing Game?

Asked by 8 years ago

I keep having this one error with my scripts where if I edit it a certain way, studio crashes when it tries to load the game.

Note: This is a Normal script in ServerScriptService

Code Issue: When I use this code, the script runs fine

while true do
if game.Players.NumPlayers > -1 then
    gameReady = true
else
    local m = Instance.new("Hint", workspace)
    m.Name = "PlayersHint"
    m.Text = "There needs to be 2 or more Players for the game to start." 
    gameReady = false
    end
end

but when I use this code, it crashes:

while true do
if game.Players.NumPlayers > 0 then
    gameReady = true
else
    local m = Instance.new("Hint", workspace)
    m.Name = "PlayersHint"
    m.Text = "There needs to be 2 or more Players for the game to start." 
    gameReady = false
    end
end

The only thing that changes is the number of players needed

Answer this question