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

Script won't start when there's more that 2 players?

Asked by
xPolarium 1388 Moderation Voter
9 years ago

I have a script for a game that features TDM. Below I have the beginning and part of the end of the entire script. I've shortened it down to where I think is the problem. If needed, below the shortened script is a pastebin link to the entire one. So if anyone can help me do something better or fix what I've done wrong? Thanks.

Problems I'm having: MESSAGE stays stuck at "WAITING FOR PLAYERS". Line 4. No errors in the log.

repeat

print("GameStart!")
game.StarterGui.Msg.MESSAGE.Text = "WAITING FOR PLAYERS"
wait(1)
game.StarterGui.Msg.MESSAGE.Text = "LOADING."
wait(1)
game.StarterGui.Msg.MESSAGE.Text = "LOADING.."
wait(1)
game.StarterGui.Msg.MESSAGE.Text = "LOADING..."

repeat
        wait()
until game.Players.NumPlayers > 2

local get = game.Players:GetChildren()
game.StarterGui.Msg.MESSAGE.Text = "SELECTING TEAMS..."
wait(1)
if game.Players.NumPlayers == 2 then
        for i = 1,#get do
        get[math.random(1, #get / 1)].TeamColor = BrickColor.new("Bright red")
        if get[i].TeamColor ~= BrickColor.new("Bright red") then
                get[i].TeamColor = BrickColor.new("Bright blue")
        else
        end
end

-- This is below the entire script and closes off the first repeat
until not game.StarterGui.Msg:findFirstChild("MESSAGE")

Pastebin: SCRIPT

0
you should not be changeing the text in StarterGui you need to go throught game.Player.[player name].playeGui then edit the text User#5423 17 — 9y
0
This is a script and not a local script so that wouldn't make sense. The problem is not that since it's working, as I said, but the problem is after that... xPolarium 1388 — 9y
0
You are missing a "until" for the first repeat. woodengop 1134 — 9y
0
Why don't you just check the number of players when a player enters? parkderp1 105 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

14 until game.Players.NumPlayers > 2 15

16 local get = game.Players:GetChildren() 17 game.StarterGui.Msg.MESSAGE.Text = "SELECTING TEAMS..." 18 wait(1) 19 if game.Players.NumPlayers == 2 then

In lne 14 you said >2 players, Then in 19 you said Equal to 2 players, It would be >= or just >.

Ad

Answer this question