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

My team won't set... help?

Asked by 10 years ago

The problem I'm having is that whenever I set the players team to white, it doesn't set it. Help is needed D:

time = 0 -- For safety concerns
while true do -- Loop timer so it works
    time = time + 1
    print(time) 
    function kill() -- Kill all players
        playerNames = game.Players:GetChildren()--Find the names of all the players
            for i = 1, #playerNames do ----repeat until all the players are killed
            game.Workspace[playerNames[i].Name].Humanoid.Health = 0 ----kill the player
        end ----finished
    end -- Ends the kill() function
    if time >= 30 then --Time for people to choose character
        kill() -- Runs the kill() function
        wait(20) --The game runs

--RIGHT HERE
        playerNames = game.Players:GetChildren() ----Find the names of all the players
        playerNames.TeamColor = BrickColor.new("White") -- Sets all player's team to spectator
        kill() -- Runs the kill() function
--RIGHT HERE

        time = 0 -- Resets the timer
    end -- Ends the "if" statement
    print(time) -- for debugging
    wait(0.9) -- Wait 1 second so it doesn't keep looping at hyperspeed until the game crashes
end -- Ends the loop

2 answers

Log in to vote
1
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

You want to change team colors through a loop. Put this portion of script on line 17

for i=1, #playerNames do --So for every player, this runs each time.
playerNames[i].TeamColor = BrickColor.new("White") --So based on index value (i) that player's team color changes.
end

You see, with your script you were trying to change the TeamColor of a table. That's what GetChildren is, a table of values. So the players are a value, you want to change the value. So you change the value's team color to white through a loop.

0
you forgot a DO but other than that i think it will work dlange95 15 — 10y
0
Oh, thank you for that, you see I am on iPad and I must have missed that. M39a9am3R 3210 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

I'm not quite sure what your time variable is supposed to be doing, but just remember, it is just a variable, so it's only a number within your script. I think, I have found the answer though

playerNames.TeamColor = BrickColor.new("White")

This is an old way of naming brick colors. I actually just mad the same mistake today, so this is how you do it properly

playerNames.TeamColor=BrickColor.White()

Hope this helps! If it doesn't, sorry. I'm still new to all of this stuff, but I hope I can help you as best as I can :D

0
tryed it, didn't work.... have no idea what to do next "{ dlange95 15 — 10y
0
You might want to check the wiki on Brick Colors, both methods are correct. M39a9am3R 3210 — 10y

Answer this question