I am trying to make a game with rounds and a intermission and then regenerate the map but idk how to fix this. Here is my script.
local RoundLength = 10 -- How long the rounds are in seconds.
local IntermissionLength = 5 -- How long the intermission is in seconds.
local RoundStartTime -- To tell when the round starts.
local map = game.workspace.Map
local function initialize()
local MapCopy = map:Clone()-- A copy of the map
MapCopy.Name = "MapCopy"
MapCopy.Parent = game.Workspace
RoundStartTime = tick() -- Tick = What current time is in seconds.
end
local function cleanup()
game.Workspace.MapCopy:Destroy()
end
map.Parent = game.ServerStorage
while true do
initialize()-- Puts current time in round start time.
repeat
local CurrentTime = tick()
local TimeSinceGameStarted = CurrentTime - RoundStartTime
until TimeSinceGameStarted > RoundLength
cleanup()
wait(IntermissionLength)
end

1 comment
use .Workspace instead of .workspace :Remove() instead of :Destroy() (this isnt a solution, just some tips)