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

How do I make a random two person teleport script?

Asked by 10 years ago

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

Log in to vote
1
Answered by
Minifig77 190
10 years ago

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

Ad

Answer this question