Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help With Team Setting Issues?

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?

5 comments

0

Any Errors?

0

Nope, no errors

0

What exactly is NS?

0

Mind changing :GetChildren() to :GetPlayers() instead?

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.

1 answer

✓ Accepted answer
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.

This discussion is preserved as it was. New answers, comments, and votes are closed.