Map spawning too early (NOT SOLVED)

Hi there, i’m new to coding so im not very good at it. So im trying to make a map appear when the game starts but the map appears during the intermission which it shouldn’t, so then the map leaves early mid game. I’m not the best scripter so i don’t know how to fix it. So any help works!

local MapTable = { -- Map Table
	1            -- Theres more maps but for the example theres one
}


	
local RandomNumber = math.random(1, #MapTable)
local RandomMap = MapTable[RandomNumber]
print(RandomMap)

local function Map () -- Chosen Map.
	while true do
		if RandomMap == 1 then
			wait(10)
			game.ReplicatedStorage.CastleTown.Parent = game.Workspace
			wait(20)
			game.Workspace.CastleTown.Parent = game.ReplicatedStorage
			local RandomNumber = math.random(1, #MapTable) 
			local RandomMap = MapTable[RandomNumber]
			print(RandomMap)
		end
	end	
end

spawn(Map) -- Repeats the process

robloxapp-20230414-1611597.wmv (3.4 MB)

Where is the intermission/end of game section of the script?

Got this script from some video on youtube

Regular script

local roundLength = 20 -- Length of round.
local intermission = 10 -- Intermission for the next round.
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status

local GameAreaSpawn = game.Workspace.GameSpawn
local LobbySpawn = game.Workspace.LobbySpawn

InRound.Changed:Connect(function()
	wait(1)
	if InRound.Value == true then
		for _, player in pairs(game.Players:GetChildren()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame = GameAreaSpawn.CFrame
		end
	end
end)



local function roundTimer ()
	while wait do
		for i = intermission, 1, -1 do
			InRound.Value = false
			wait(1)
			Status.Value = "Intermission: ".. i .." Seconds left!"
		end
		for i = roundLength, 1, -1 do
			InRound.Value = true
			wait(1)
			Status.Value = "Game: ".. i .." Seconds left!"
		end
	end
end

spawn(roundTimer)

Local Script

local Status = game.ReplicatedStorage.Status
local TimerDisplay = script.Parent.Frame.TimerDisplay

Status.Changed:Connect(function()
	TimerDisplay.Text = Status.Value
end)