Getting players of a team

Hello everyone,
I am trying to get all players of a team and teleport them somewhere, but even though I have some players in the team the table doesnt seem to get any of them.

function LoadPlayer()
	if workspace.Map then
		local PlayerTable = game.Teams.XYZ:GetChildren()
		for i, v in pairs(PlayerTable) do
			v.Character.HumanoidRootPart.CFrame = workspace.Map.Spawn.CFrame
		end
	end
end

I have tried to look at the other posts and videos about this but I cant figure out whats going wrong here.

4 Likes

Try the function called GetPlayers()

game.Teams.XYZ:GetPlayers() should return a table of all players in the team.

5 Likes

Yeah that works! But isn’t what I am doing does the same thing? Or am I not understand something?

GetChildren would get the actual instances inside the team. (Parts, Models, etc.)

GetPlayers will search every player’s team, and if it is in that team, it would return the player, all in a table.

2 Likes