How can I make a script that choises a random map from lighting, then teleports everyone from the lobby to the map??
✓ ANSWER ACCEPTED
How to make a map chooser?
1 answer
✓ Accepted answer
I highly recommend you use ServerStorage for something like this, not Lighting.
First you need to decide a random map and then teleport all players to a specific part in your map. This code is very simple since I think you're a beginner.
--Map
maps = game.ServerStorage.Maps:GetChildren()
map = maps[math.random(1, #maps)]
map:Clone().Parent = game.Workspace
--Only use this code if you want to teleport all players to one spawn.
for _,player in pairs(game.Players:GetPlayers()) do
if player.Character then
player.Character:MoveTo(game.Workspace.MapName.MapSpawn.Position)
end
end
--Only use this code if you want to teleport all players to more than one spawn.
for _,player in pairs(game.Players:GetPlayers()) do
if player.Character then
spawns = map.Spawns:GetChildren()
player.Character:MoveTo(spawns[math.random(1, #spawns)].Position)
end
end
--Only use this code if you want to teleport all players but one to a different spawn.
players = game.Players.GetPlayers()
different = players[math.random(1, #players)]
if different.Character then
different.MoveTo(map.RedSpawn.Position)
end
for _,player in pairs(game.Players:GetPlayers()) do
if player.Character and player.Name ~= different.Name then
player.Character:MoveTo(map.BlueSpawn.Position)
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

19 comments
I'm not a beginner, I'm just not good. I can do basic stuff like editing and making some simple stuff
and how can I make it so it tps the players to 2 different spawns, like a red and blue. and is there a way to make it so that 1 player tps to red spawn and the rest go to blue spawn, like deathrun??
or another example is like murder mystery, where 1 player is picked to be killer or on 1 team and the rest are tp to a different area??
Let me modify it for random spawns.
ok, i only want 2
like there is only 2 blocks in the map, 1 called BlueSpawn, one called RedSpawn, where the 1 person in red spawns in the block and the rest spawn in the blue block
There you go. You can have any number you want, it doesn't matter.
So this final script will have players spawn in a lobby, then take them to a map with 1 person being a red and the rest being a blue??? WIll I be adble to a GUI that tells the people before the game what map has been chosen??
Nope, I made another script for that. If it doesn't work then let me try again
the script dosent look like it will make 1 person tp to 1 spawn and every other playr to a different one??
Yes, it will teleport one player to a single spawn and the rest to random spawns. If you want it to be one single spawn, tell me
Also players can not teleport to that single spawn that the person spawns at
I just want something like deathruns one, where they have 1 killer and 13 runners, then when a runner reaches the end they tp to kill the killer
Yes, that's exactly what I just made.
I just modified it so it only goes to one spawn. That's what I just made. Have a nice day.
Ok thanks sooooooooooo much.
Hey I need help, should the map model which contains the maps, shoudl it be "maps" or "Maps"
line 30 says that I need a ] near )
Fixed, and it should be Maps.