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

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

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

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)

2 comments

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.

0

@coo1o, you may have overlooked the comment in the Code Bock I posted that reads "assuming this is in a LocalScript" ;)

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