I found a map script in here by searching it, but apparently it didn't work for some reason. This is how I set it up in Workspace, ServerScriptService, and ServerStorage.
MapScript:
maps = game.ServerStorage.Maps:GetChildren() function loadMap(map) table.foreach(Workspace.currentMap:GetChildren(), function(i,v) v:Remove() end)--remove children nmap = map:Clone() nmap.Parent = game.Workspace.currentMap nmap:MoveTo(Workspace.mapLocation) end function randMap() loadMap(maps[math.random(1,#maps)]) end
Workspace:
--LobbySpawn (Spawned in Lobby after race) --MapHolder (Model) --Map1Beginner (Map1Model) --Map2Turning (Map2Model)
ServerStorage:
--Maps (Model) --Map1Beginner (Map1Model) --Map2Turning (Map2Model) --RaceCar (Map1 Car) --RaceCar (Map1 Car) --RaceCar (Map2 Car) --RaceCar (Map2 Car)
ServerScriptService:
--MapScript (MapScript that I showed above) --Map1 (For Map1) (Link for what the map script looks like: https://scriptinghelpers.org/questions/19819/how-do-i-make-the-321-imagelabel-work-in-this-script) --Map2 (For Map2)
I hope you understand what I am saying here. :)
You forgot to adjust Workspace.currentMap
and Workspace.mapLocation
to your needs here.
local maps = game.ServerStorage.Maps:GetChildren() --Whatever you have above all code in the script, you can mostly set it to local function _G.loadMap() --So you can call this function in all scripts local map = maps[math.random(1,#maps)] table.foreach(Workspace.MapHolder:GetChildren(), function(i,v) v:Remove() end)--This basically removes the map nmap = map:Clone() nmap.Parent = game.Workspace.MapHolder nmap:MoveTo(Vector3.new(0,0,0)) --Put the Vector3 of where you want the map to be here. But, as the map is probably a Model, be careful - if you haven't set a PrimaryPart (The part which will be affected and will be the center of all movement operations targeted on the model) the root part will be used instead. The root part is probably the very first part you put in the model, or the most in the center of the bounding square when you select it. Anyway, you don't need you set a PrimaryPart - just experiment with the placement in the command bar and see where it fits! end