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
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
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
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
-- 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")
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)
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.