local Map = game.Workspace.Map local number = 5 function reloadMap() game.Workspace.Map.Parent = game.ReplicatedStorage wait(1) game.Workspace:ClearAllChildren() wait(1) game.ReplicatedStorage.Map.Parent = game.Workspace for _,v in pairs(game.Players:GetPlayers()) do -- how do i make it work like i want v:LoadCharacter() end end while wait(number)do reloadMap() end -- If there is an easier way to clear workspace without deleting the player and unwanted folders please tell me.
add another for _, v in pairs loop before respawning the players and put it instead of what you have clearing the workspace now:
for _, v in pairs(workspace:GetChildren()) do if not game.Players:FindFirstChild(v.Name) and not v.Name == "Terrain" then --[[ Checking if the models name is a player name ]] v:Destroy() -- Destroys it if it isn't. end end
This should destroy everything in workspace besides parts with a players name or terrain. May have spelled terrain wrong btw..