Currently, I’ve noticed that about 1-4 players leave the game when the match is over and the map starts to unload, and teams all spectator. They might be crashing, can’t be sure. But still, players do say they experience lag when this happens. It’s understandable since there are about 20-30 players being teamed all spectator while the map is being removed. They only experience the lag when this is happening, about 2-5 seconds.
Is there a possibility that I can reduce the lag for the players, so they can enjoy it better?
This is the code sample:
-- loads in terrain
workspace.Terrain:PasteRegion(game.ServerStorage.Storage.Terrain[MapA.Name], workspace.Terrain.MaxExtents.Min, true)
-- After the match, it starts to remove map and team all spectator.
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
if v ~= nil then
local success, err = pcall(function()
v.Team = game:GetService("Teams"):FindFirstChild("Spectator")
end)
local successs, errr = pcall(function()
v:LoadCharacter()
end)
wait()
end
end
wait(1)
-- END
workspace.Terrain:Clear()
I understand that 2-5 seconds of lag every 15 minutes isn’t a big deal, but I still would like some input, much thanks!