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

How would i make it so where only a team will teleport to a position?

Asked by 6 years ago

**Im trying to make a UFC game where only the team of red and blue teleport to the ring and like when they come into the ring it freezes them and gives them a tool but i want to know how to make only the team i want teleport to a position i put.

**

2 answers

Log in to vote
0
Answered by 6 years ago

Hello! I will answer this question in a structured way:

You would first have to trigger the script. Then, you get the players in the game using game:GetPlayers()

Save that to a variable
and then use the for loop to check if they are in a team.
    If they are
         teleport them.
    end
end

end

Enjoy!

Ad
Log in to vote
0
Answered by 6 years ago

MarketManager1 wasn't very descriptive in his answer, so i'll add on.

The actual way to do this would be in the following lines of code:

local teamColor = BrickColor.new("Really red") --Set the teamcolor here
local thePosition = Vector3.new(0,0,0) --Set the vector here
for i,v in pairs(game.Players:GetPlayers()) do
    if(v.TeamColor == teamColor) then
        v.Character:MoveTo(thePosition)
    end
end

Basically, what's happening in the script is it is getting all the players currently on the server and looping through them. If the player is on a specific team, which is determined by Player.TeamColor, then they will be moved to a position of your choice.

The only way to actually see if the player is on that team is through the team's color. This is a BrickColor value which indicates the color that team will appear on the player list provided by ROBLOX. When a player is on that team, their TeamColor variable will change to the brickcolor of that team.

Example

Say you made a team called "Red Team", and set it's color to "Really red". Once a player were to join that team, their TeamColor would automatically change to "Really red".

The other variable defined, thePosition, is the position at which all the players would be teleported. Say there's a part at the position "26, 104, 662". If you set thePosition to Vector3.new(26, 104, 662), then each player would be moved to "26, 104, 662".

I hope I didn't over complicate things, so feel free to ask me more if you still need help.

Answer this question