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

How Do I Teleport Teams to opposite sides?

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.

1 comment

0

if you're working with the team service, you know you can create 2 new team instances, create two spawn points and then assign the team to the spawn point, they'll automatically spawn there

1 answer

✓ Accepted answer

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

3 comments

0

This isn't what I need, I already know how to teleport a player, I want the teleport script to be Team specific. So People on the red team get teleported to one part, and people on the blue team get teleported to a different part

0

ok, I edited my answer

0

Thanks this worked, I had an error for a bit but figured it out. I forgot to add back .CFrame when putting in my own variable.

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