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

How to make a map chooser?

Asked by 10 years ago

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

1 answer

Log in to vote
1
Answered by
DevChris 235 Moderation Voter
10 years ago

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
1
I'm not a beginner, I'm just not good. I can do basic stuff like editing and making some simple stuff NinjoOnline 1146 — 10y
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?? NinjoOnline 1146 — 10y
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?? NinjoOnline 1146 — 10y
0
Let me modify it for random spawns. DevChris 235 — 10y
View all comments (15 more)
0
ok, i only want 2 NinjoOnline 1146 — 10y
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 NinjoOnline 1146 — 10y
0
There you go. You can have any number you want, it doesn't matter. DevChris 235 — 10y
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?? NinjoOnline 1146 — 10y
0
Nope, I made another script for that. If it doesn't work then let me try again DevChris 235 — 10y
0
the script dosent look like it will make 1 person tp to 1 spawn and every other playr to a different one?? NinjoOnline 1146 — 10y
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 DevChris 235 — 10y
0
Also players can not teleport to that single spawn that the person spawns at DevChris 235 — 10y
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 NinjoOnline 1146 — 10y
0
Yes, that's exactly what I just made. DevChris 235 — 10y
0
I just modified it so it only goes to one spawn. That's what I just made. Have a nice day. DevChris 235 — 10y
0
Ok thanks sooooooooooo much. NinjoOnline 1146 — 10y
0
Hey I need help, should the map model which contains the maps, shoudl it be "maps" or "Maps" NinjoOnline 1146 — 10y
0
line 30 says that I need a ] near ) NinjoOnline 1146 — 10y
0
Fixed, and it should be Maps. DevChris 235 — 10y
Ad

Answer this question