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

How to make a map chooser?

How can I make a script that choises a random map from lighting, then teleports everyone from the lobby to the map??

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

19 comments

1

I'm not a beginner, I'm just not good. I can do basic stuff like editing and making some simple stuff

0

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??

0

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??

0

Let me modify it for random spawns.

0

ok, i only want 2

0

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

0

There you go. You can have any number you want, it doesn't matter.

0

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??

0

Nope, I made another script for that. If it doesn't work then let me try again

0

the script dosent look like it will make 1 person tp to 1 spawn and every other playr to a different one??

0

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

0

Also players can not teleport to that single spawn that the person spawns at

0

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

0

Yes, that's exactly what I just made.

0

I just modified it so it only goes to one spawn. That's what I just made. Have a nice day.

0

Ok thanks sooooooooooo much.

0

Hey I need help, should the map model which contains the maps, shoudl it be "maps" or "Maps"

0

line 30 says that I need a ] near )

0

Fixed, and it should be Maps.

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