Help on this intermission script

Can you please list all the errors and rewrite the script to something working. Please also explain why they dont work.

local Event = script.Parent

local IntermissionTime = 15
local PlayersInServ = nil

RoundStarted = false
NoData = nil

Debugging = true

PlayerUsername = nil

Event.OnServerEvent:Connect(function()
	for _, player in pairs(game.Players:GetChildren()) do
		local char = player.Character
		char.HumanoidRootPart.CFrame = game.Workspace.Assets.Map.ScriptAccess.BaseTeleporterPoint.CFrame
		task.wait()
		print("Teleport complete | Round Started")
	end
end)

game.Players.PlayerAdded:Connect(function(plr)
	print(plr.Name.." has joined!")
	PlayerUsername = plr.Name
	while true do
		PlayersInServ = #plr:GetChildren()
		local IntermissionText = plr.PlayerGui.Intermission.IntermissionText
		IntermissionText.Text = "Please wait for more players!"
		if PlayersInServ > 2 then
			FireIntermission()
			print("Starting Round Intermission")
			wait(0.5)
			if PlayersInServ == nil then
				print("Server is vaild but PlayersInServ is nil")
				IntermissionText.MouseEnter:Connect(function()
					plr.PlayerGui.Intermission.DescriptionText.Visible = true
					if IntermissionText.Visible == true then
						plr.PlayerGui.Intermission.DescriptionText.Visible = false
					end
				end)
				IntermissionText.MouseLeave:Connect(function()
					plr.PlayerGui.Intermission.DescriptionText.Visible = false
				end)
			end
		end
	end
end)

function FireIntermission()
	script.Parent.Parent.IntermissionStarting:FireAllClients()
end

function CheckIfTouchingBase()
	if RoundStarted == false then
		game.Workspace.Assets.Map.ScriptAccess.Base.Touched:Connect(function(hit)
			local h = hit
			if h then
				local plr = game:GetService("Players").LocalPlayer
				plr:Kick("You've been kicked for touching the Base while RoundStarted = false")
				task.wait()
				print("Kicked "..plr.Name.." for touching BasePart while RoundStarted = false")
			elseif RoundStarted == true then
				NoData = true
				wait(1)
				NoData = false
			end
		end)
	end
end

if RoundStarted == true then
	print("Round has started")
elseif RoundStarted == false then
	CheckIfTouchingBase()
	while wait(0.5) do
		if NoData == true then
			print("Mistake on plr kick()")
		end
	end
end

if Debugging == true then
	game.Players.PlayerAdded:Connect(function()
		print("Debugging in 10 seconds")
		task.wait()
		wait(10)
		debug()
	end)
end

local RoundEndedEvent = Instance.new("RemoteEvent")
RoundEndedEvent.Name = "RoundEnded"
RoundEndedEvent.Parent = game.ReplicatedStorage

game.ReplicatedStorage.RoundStarted.OnServerEvent:Connect(function()
	
	RoundStarted = true
	task.wait()
	
	local RoundTime = Instance.new("IntValue")
	RoundTime.Value = 180
	RoundTime.Name = "RoundTime"
	RoundTime.Parent = game.ReplicatedStorage
	
	while wait(1) do
		RoundTime.Value -= 1
	end
	while true do
		if RoundTime.Value == 0 then
			RoundTime:Remove()
			RoundStarted = false
			RestartIntermission()
		end
	end
end)

function RestartIntermission()
	local findplr = game.Players:FindFirstChild(PlayerUsername)
	if findplr then
		print("Found player | "..findplr)
		findplr.PlayerGui.Intermission.IntermissionText.Text = "Waiting for game..."
		wait(2)
		game.ReplicatedStorage.IntermissionStarting:FireAllClients()
		print("Starting Intermission (function RestartIntermission())")
	end
end

Well I saw you fired a function before even writing it so that may be the problem, you gotta make a function first before firing it or am I wrong