Maps lagging when loading

Hey all. Is there anyway to improve map loading? when ever a map loads from my game i often have like 2 or 3 seconds of lag. Is there anyway to improve this system?

– Script --------------------------------------------------------------------

GameTime = 5 – In Minutes
Music = game.Workspace:WaitForChild(“Music”)
debris = game:GetService(“Debris”)
Players = game:GetService(“Players”)
SS = game:GetService(“ServerStorage”)
Maps = SS:WaitForChild(“Maps”)

CurrentMap = script.Parent.Parent:WaitForChild(“CurrentMap”) – Current map in your world
Image = script.Parent.Parent:WaitForChild(“Image”)
MapCreator = script.Parent.Parent:WaitForChild(“MapCreator”)

Timer = script.Parent:WaitForChild(“GameTime”)
TimerMinutes = Timer:WaitForChild(“Minutes”)
TimerSeconds = Timer:WaitForChild(“Seconds”)
EnableTimer = script.Parent.Parent:WaitForChild(“TimerEnabled”)

TimerMinutes.Value = GameTime
EnableTimer.Value = true

----- FUNCTIONS -----------

function LoadMap(Map, Creators, MapImageId)
CurrentMap.Value:Destroy()
CurrentMap.Value = nil

```
Image.Value = MapImageId
MapCreator.Value = Creators

local NewMap = Map:Clone()
NewMap:MakeJoints()
NewMap.Parent = game.Workspace
CurrentMap.Value = NewMap

print("Loaded " .. Map.Name)

TimerMinutes.Value = GameTime
TimerSeconds.Value = 0
EnableTimer.Value = true

for i, player in pairs(Players:GetPlayers()) do
	local H = player.Character:FindFirstChild("Humanoid")
	if H then
		H.Health = 0
	end
end
```

end

----- END OF FUNCTIONS ------

while true do
wait(GameTime * 60)
LoadMap(Maps[“Gladiator Zone”],“Ethanthegrand14”,3938377605)
wait(GameTime * 60)
LoadMap(Maps[“Volcanic Lands”],“Ethanthegrand14”,3942548162)
end
2 Likes

Hi, can you please put the script in code format. Simply select the code, and click a button that looks like this:
</>

That way, it is easier to read.
Thanks.

2 Likes

oh, never knew i could do that. Thanks.

2 Likes

youre loading the map all at once, which of course is gonna take a toll on the performance, try creating a folder with the maps’ name and just copy each thing over one by one, its gonna be slower, but with less strain

2 Likes

Thanks. I’ll try out this technique later today