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

Help With Team Setting Issues?

Asked by
Scootakip 299 Moderation Voter
8 years ago
for i,player in pairs(game.Players:GetChildren()) do
    player.TeamColor = BrickColor.new("White")
    local torso=player.Character:FindFirstChild("Torso")
    torso.CFrame=NS+Vector3.new(0,i*5,0)
    if player.Backpack.pie ~= nil then
        player.Backpack.pie:Destroy()
    end
end

This is basically supposed to set all of the player's teams to White, but for some reason it only sets 1 or 2 players to that team rather than everyone. Some help?

0
Any Errors? rexbit 707 — 8y
0
Nope, no errors Scootakip 299 — 8y
0
What exactly is NS? rexbit 707 — 8y
0
Mind changing :GetChildren() to :GetPlayers() instead? XAXA 1569 — 8y
3
A few things that may be causing this to error. 1 is that GetChildren() isn't all too good because when a player leaves it tends to glitch. 2 You aren't checking to make sure that the player DOES exist or if the character exist. 3 You should use :findFirstChild("pie") on line 6, because a lot of times the script errors due to the object being nil. OneTruePain 191 — 8y

1 answer

Log in to vote
0
Answered by
Acheo 230 Moderation Voter
8 years ago
for i,player in pairs(game.Players:GetChildren()) do
    player.TeamColor = BrickColor.new("White")
    local torso=player.Character:WaitForChild("Torso")
    torso.CFrame=NS+Vector3.new(0,i*5,0)
    if player.Backpack:FindFirstChild("pie") ~= nil then
        player.Backpack.pie:Destroy()
    end
end

Tell me if it works, there we lots of things in there that could've been fixed incase of an error so I did it for you.

Ad

Answer this question