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

How to make all the players in one place teleport to a random place?

Asked by 10 years ago

I need a script that teleports players to a random place in a universe. I'm creating an FPS with a lobby and I want it to teleport to a random place in that universe. How do I do this?

1 answer

Log in to vote
0
Answered by
duckwit 1404 Moderation Voter
10 years ago

Create a table of placeids and then use the math.random() random number generator to choose one of them from the table randomly:

places = {1818, 1457, 16745}  --Fill this table with the id's for the different places
chosenPlace = places[math.random(1,#places)]

--Assuming this is in a LocalScript
game:GetService('TeleportService'):Teleport(chosenPlace)
0
Is this a server script or a LocalScript? If it's a server script then you're missing the player argument for the teleport. coo1o 227 — 10y
0
@coo1o, you may have overlooked the comment in the Code Bock I posted that reads "assuming this is in a LocalScript" ;) duckwit 1404 — 10y
Ad

Answer this question