Making Map Choosing System

I want to make a map choosing system in the lobby when the player enter elevator then the Maps chosing Gui pop up to tell him what map he want then after he clicked the map he want and then wait some more player to join the elevator with him then teleport him to that map.

My brain rn not working idk what to do. Any helps or explains will help me alot thanks :+1::nerd_face:

one more thing i forgot to says is that i did the Gui Pop Up part when he enter the zone and exit the zone but idk about the other part

Dont ask others to make entire scripts for you

1 Like

i dont ask the entire script i know how to do that but i cant think about it. I just want some explains like what i should do

1 Like

i mean like i dont know where to start

Well ur request is pretty advanced, And im not really at that lvl yet

But the GUI Popping up on the players screen is easy: Just show it to them once they get in the elevator, The GUI Should be an ImageButton, Once you click at one of those, Well, Ya know what happens

1 Like

Yeah i know how to make the gui pop up and close it but for the other part i have no ideal

You mean the part where the player gets teleported?

its when the player choose what map he want on the GUI then teleport him to that specific map

i have to make a script for each button??

You could probably start the code in which the player chooses the map like:

local chosen = ""

local GUI = script.Parent

local maps = GUI.Maps:GetChildren() --Frame called "Maps" filled with image buttons of each map.

for _, map in pairs(maps) do
	if map:IsA("ImageButton") then
		map.MouseButton1Click:Connect(function()
			
			chosen = map.Name
			--print(chosen)
--Other code
			
		end)
	end
end
1 Like

You would just need to check what map was chosen and teleport the player to the map

1 Like

about the map teleport. I have to make a table like

local mapsTable = {Grassland[GameID], Wastleland[GameID]}

right?

I don’t think that’s an effective way to do it. Perhaps like this would do:

local mapsTable={
	{["GAMENAME"] = "Grassland", ["GAMEID"] = 0000000000},
	{["GAMENAME"] = "Wastleland", ["GAMEID"] = 0000000000},
}
1 Like

Can you give me more explains like how would i check if a player choose that map and look for it in the table

You could do a similar built-in pairs() function in a for loop, like what i did in the first code, and check if any of the “GAMENAME” is similar to the chosen map name using the “if […] then” condition. Then, you could create a variable to get the game id from that.

e.g,

for g, gameid in pairs(gameids) do
				if gameids[g].GAMENAME == chosen then
					local teleport = gameids[g].GAMEID
					
					print(teleport)
				end
			end
1 Like

I’d do something like this:

-- Imagine the Grassland Map ID is 1000
-- Imagine the Wasteland Map ID is 1200
local mapsTable = {
	["Grassland"] = "1000",
	["Wasteland"] = "1200"
}

-- Now when you want to open a map you can get the ID from the array using the name
local function LoadMapFromName(mapName):
	local mapID = mapsTable[mapName]

	-- Then you can load the map however you're doing that
	LoadMapFromID(mapID)
end

-- When the player presses the wasteland button
LoadMapFromName("Wasteland")
2 Likes

Thanks guys gotta try its out then i will mark which solutions i found work best! :smiley:

sorry for bothering you but currently its only printing out the “Grassland” game id, the other one didnt
here my current script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TeleportService = game:GetService("TeleportService")
local ChooseMapEvent = ReplicatedStorage.Events:WaitForChild("MapChoosing")
local mapsTable={
	{["GAMENAME"] = "Grassland", ["GAMEID"] = 10890055054},
	{["GAMENAME"] = "Isometric-Ruin", ["GAMEID"] = 10979968228},
}

function ChoosingMap(player,choosedMap)
	print(player,choosedMap)
	for g, gameid in pairs(mapsTable) do
		if mapsTable[g].GAMENAME == choosedMap then
			local teleport = mapsTable[g].GAMEID
			print(teleport)
		end
	end
end	
ChooseMapEvent.OnServerEvent:Connect(ChoosingMap)

Try this:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TeleportService = game:GetService("TeleportService")
local ChooseMapEvent = ReplicatedStorage.Events:WaitForChild("MapChoosing")

local mapsTable={
	["Grassland"] = "10890055054",
	["Isometric-Ruin"] = "10979968228"
}

function ChoosingMap(player,choosedMap)
	print(player,choosedMap)
	local teleport = mapsTable[choosedMap]
	print(teleport)
end	
ChooseMapEvent.OnServerEvent:Connect(ChoosingMap)

I may be misunderstanding what you’re trying to do, but this seems to be a simpler solution that does the same thing.

2 Likes