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

Why is there a NumPlayers problem?

Asked by 8 years ago

I'm confused as to why when I use Code1 and test it in a server it works, but when I use Code2 and test it with a friend it doesn't work

Code1:

while true do
    wait()
if game.Players.NumPlayers >= 1 then
    gameReady = true
    break
else
    timer.Value = "There needs to be 1 or more Player for Towergames to start."
    gameReady = false
    end
end

Code2:

while true do
    wait()
if game.Players.NumPlayers >= 2 then
    gameReady = true
    break
else
    timer.Value = "There needs to be 2 or more Players for Towergames to start."
    gameReady = false
    end
end

1 answer

Log in to vote
0
Answered by 8 years ago

Wait() Pauses a script, you know. So basically I'd do this:

while true do
    wait() until game.Players.NumPlayers > 1
    round()
    wait(1)
end

And put a function in the same script like this:

function round()
    -- PUT YOUR CODE HERE
end
0
"ServerScriptService.GameScript:8: 'end' expected (to close 'while' at line 7) near 'until'" User#9949 0 — 8y
0
JUST LEMME IN STUDIO AND LET ME SEE THAT SCRIPT! NeonicPlasma 181 — 8y
Ad

Answer this question