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 make a player be teleported to a certain place based on their team?

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

✓ Accepted answer

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

5 comments

1

^ You can also use math to make sure people do not teleport into each other.

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.

0

By the way, it should be :GetPlayers() instead.

0

And not all "good" games necessarily require players not colliding. Games have their reasons to go either way.

0

Ah yes, I made a spelling error. My bad. But yes, it should GetPlayers() and supposedly Collision Group is the way to go.

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