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

How do you find out which team a player is on?

I only want players on a certain team to teleport to a certain location. Here is my script so far...

select = game.Players:FindFirstChild()
if select.TeamColor =  BrickColor.new("Bright red")
then 
wait (30)
select.Character.Torso.CFrame = CFrame.new(Vector3.new(game.Workspace.telebrick))
else
select.Character.Torso.CFrame = CFrame.new(Vector3.new(game.Workspace.telebrick))

Is this script going to work? Please don't send me to wiki because I already looked there...

2 answers

✓ Accepted answer

You can use Team:GetPlayers() to get a list of all of the players on a team. http://wiki.roblox.com/index.php?title=API:Class/Team/GetPlayers

local telebrick = workspace.telebrick
for _, player in pairs(game.Teams.Red:GetPlayers())do
	local torso = player.Character:FindFirstChild("Torso")
	if torso then
		torso.CFrame = telebrick.CFrame
	end
end

I do advise that you give a random offset to everybody's teleported position, otherwise they will all be in the exact same place and might explode. Another offset is necessary as well if "telebrick" is also a solid object that you're trying to place the characters inside of.

I can answer 90% percent of this. So your code

select.Character.Torso.CFrame = CFrame.new(Vector3.new(game.Workspace.telebrick))

Should be:

select.Character.Torso.CFrame = CFrame.new(CFrame.new(game.Workspace.telebrick.CFrame))

That's all I got sorry I cant help more.

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