I'm trying to teleport two different teams to opposite areas, I have the teleport code I just need for them to be team specific. I've looked at other people's code and they say to use ( if ~~~~~~~~~~~~~~~~~ Player.Team.Name == "TeamIWannaTP" then --Teleport code end else ~~~~~~~~~~~~~~~~~ and so on. I want the code to be able to run in a server script, I think that's the only way to teleport anyways. Right? Idk I'm kinda new to scripting so if anyone could help me out.
You can teleport a character by moving the HumanoidRootPart's CFrame:
Player.Character.HumanoidRootPart.CFrame = CFrame.new(0, 0, 0)
or if you have a part that you want to teleport a player to, you can do this:
Player.Character.HumanoidRootPart.CFrame = workspace.Part.CFrame
to teleport every player according to their team, you can just loop through every player and check what their team is:
for i, player in pairs(game.Players:GetPlayers()) do if player.Team.Name == "Blue" then player.Character.HumanoidRootPart.CFrame = workspace.BlueSpawn.CFrame elseif player.Team.Name == "Red" then player.Character.HumanoidRootPart.CFrame = workspace.RedSpawn.CFrame end end