Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a random two person teleport script?

I'm making a game where two random people get selected off the players list, and each of them get teleported to a different location, so player 1 would get teleported to one spot, and player 2 would get teleported to another spot. I don't know how to randomly select two different players off the players list, and have each of them get teleported. Please help.

1 answer

Basically, you would use GetChildren() to find all of the Players in game.Players. Then, use math.random to select two random players. To teleport the players, I'd use the MoveTo(Location) method.

Example:

players = game.Players:GetChildren()

players[math.random(1, #players)]:MoveTo(Vector3.new(Location1) --Change Location1 to the location of player1 when teleported.
players[math.random(1, #players:MoveTo(Vector3.new(Location2) --Change Location2 to the location of palyer2 when teleported.

If you want to move the player to a part, you'd do:

players[math.random(1, #players)]:MoveTo(part.Position)

wiki.roblox.com/index.php?title=GetChildren_(Function) http://wiki.roblox.com/index.php?title=MoveTo_(Function) http://wiki.roblox.com/index.php?title=Tables

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