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

How do I check to see what team someone is in and then TP them somewhere?

Asked by 5 years ago

I want to check someones team and TP them to the respecting bases. (If they are in blue team they will get tp'ed to blue base)

1 answer

Log in to vote
-1
Answered by
Pyracel 55
5 years ago

You will need a way to find the player and an event that causes them to get teleported. I will write a script that teleports them on spawn. This should be a regular script in ServerScriptService.

Change Team1 and Team2 text to whatever the team names are. Change Team1Spawn and Team2Spawn to the name of the spawns in workspace.

local Team1 = game.Teams:WaitForChild("Blue Team")
local Team2 = game.Teams:WaitForChild("Red Team")

local Team1Spawn = game.Workspace:WaitForChild("BlueSpawn").Position
local Team2Spawn = game.Workspace:WaitForChild("RedSpawn").Position

local Players = game.Players

Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)

    local Torso = Character:WaitForChild("Torso")

    if Player.Team == game.Teams:WaitForChild(Team1) then
    Torso.CFrame = CFrame.new(Team1Spawn.X,Team1Spawn.Y+5,Team1Spawn.Z)
    elseif Player.Team == game.Teams:WaitForChild(Team2) then
    Torso.CFrame = CFrame.new(Team2Spawn.X,Team2Spawn.Y+5,Team2Spawn.Z)
    end

end)
end)




Ad

Answer this question