Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do I Teleport Teams to opposite sides?

Asked by 3 years ago

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.

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 supercoolboy8804 114 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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
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 Papa_Frank420 14 — 3y
0
ok, I edited my answer OfficerBrah 494 — 3y
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. Papa_Frank420 14 — 3y
Ad

Answer this question