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

How do I make a player be teleported to a certain place based on their team?

Asked by 5 years ago

I am making a game called "Memory Madness" in which players must repeat a sequence of colors to survive, those who do not put in the correct sequence are eliminated. I am up to the intermission part and where players are teleported into the map. After I randomize the teams, I want to make sure that the person on the Green team gets teleported to the green spot, and that the Red team gets teleported to the red stop and so on. How would I achieve this?

1 answer

Log in to vote
1
Answered by
pwx 1581 Moderation Voter
5 years ago

Assuming you don't want to do SpawnLocations, it'd work like this.

Players = game:GetService('Players')


for _,player in pairs(Players:GetPlayer()) do
    if player.Team = game.Teams['TEAMNAMEHERE'] then
        player.Character.HumanoidRootPart.CFrame = Vector3.new(0,0,0) -- Replace with whatever vector you want.
    end
end
1
^ You can also use math to make sure people do not teleport into each other. pwx 1581 — 5y
0
Wouldn't matter. If you make collision groups between players not colliding then they won't touch, which all good games should do and have to prevent flinging. ScaleisRed 58 — 5y
0
By the way, it should be :GetPlayers() instead. Lugical 425 — 5y
0
And not all "good" games necessarily require players not colliding. Games have their reasons to go either way. Lugical 425 — 5y
0
Ah yes, I made a spelling error. My bad. But yes, it should GetPlayers() and supposedly Collision Group is the way to go. pwx 1581 — 5y
Ad

Answer this question