Please Review My Round System Script

so i have been working about a week on a round system script i have over come so ground breaking bugs but finished them and have had some help on and i was going to show you my script so you can use/ see any opmituse issue

now there are some useless varibles in there that i for got to delete

credits devs:
zerod

script:

-- Varibles -- 

local RoundSerivce = {}

-- Strings --

local Waitime = "15"
local NEP = "Not Enough Players!"
local SI =  "Intermisson: 0"
local Status = " "

-- Ints --

local LeastPlayers = 2
local TimeWaiting = 1
local IntermissonTime = 5
local MaxAmoutGiving = 100
local Roatation = 20
local Round = 0

-- Bools --

local GivenPoints = false
local notfirstRound = false
local isfirstround = true
local RoundInProgess = false
local RoundHASStarted = false

-- Tables --

local Alive = {}
local Dead = {}
local Finshed = {}
-- Serivces --

local TeleportationPart = workspace:WaitForChild("Teleportation")
local ColourPickerSerivce = require(game:GetService("ReplicatedStorage").Serivces.ColourPickerSerivce)
local Players = game.Players
local RoundStarting = game.ReplicatedStorage.Remotes:FindFirstChild("RoundStarting")



-- Functions --

-- Sever --

function CalulateTickets(PlaceMent)
	Status = "NearIntermisson"
	local PointReward = MaxAmoutGiving /  (PlaceMent*2)
	local PlayerUserid = Finshed[PlaceMent]
	local Player = Players:GetPlayerByUserId(PlayerUserid)
	
	Player.leaderstats.Tickets.Value += math.ceil(PointReward)
	print(math.ceil(PointReward))
end


function Count()
	Status = "Intermisson"
	local Playerrs = 0
	for i,v in Players:GetPlayers() do
		Playerrs += 1
	end
	return Playerrs
end

function TPPlayers(Place)
	Status = "InProgess"

	for i,plr in pairs(Players:GetPlayers()) do
		plr.Character:PivotTo(Place.CFrame + Vector3.new(0,math.random(0,25)))
	end
end

function GiveTicketsToFailure()
	Status = "InProgess"
	for i,v in Dead do
		Players:GetPlayerByUserId(v).leaderstats.Tickets.Value += 1
	end
end

function InGame(Player: Player)
	Status = "InProgress"
	local DB = false
	local function BaseTouched(hit: Instance)
		if hit.Parent:FindFirstChild("Humanoid")   then
			if DB == true then return end
			DB = true
			local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
			table.remove(Alive, table.find(Alive, plr.UserId))
			plr:RemoveTag("InGame")
			table.insert(Dead,plr.UserId)
			hit.Parent:PivotTo(game.Workspace.SpawnLocation.CFrame + Vector3.new(0,5,0))
			
			local number = 1
			for i = 1, #Alive do
				number += 1
			end
			print("There Is "..number.."People ALIVE THIS IS CHECKING FOR FINSH")

			if number == 0  then
				workspace.Baseplate:SetAttribute("OutOfPlayers",true)
				print("Appenly less 0 people but there is"..number)
			end
task.wait(1)
			DB = false
		end
	end
	local function FinshTouched(hit: Instance)
		if hit.Parent.Humanoid and DB == false then
			DB = true
			local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
			if table.find(Alive,plr.UserId) then
			
				table.remove(Alive, table.find(Alive, plr.UserId))
				plr:RemoveTag("InGame")

				table.insert(Finshed,plr.UserId)
			local Awarder =require( game.ReplicatedStorage.Serivces.StatsAwarderSerivce)
			Awarder.Touched(hit)
			task.wait(.2)
			DB =false
			end
		end
	end
	workspace.GiverParts.Awrder.Touched:Connect(FinshTouched)
	workspace.Baseplate.Touched:Connect(BaseTouched)
end

local function Check2(tab)
	Status = "InProgess"
	local num = 0
	for _,v: Player in  pairs(game.Players:GetPlayers()) do
		if v:HasTag("InGame") then
		num += 1
		end
	end
	return num
end

local function RemoveUserid()
	Status = "Intermisson"
Finshed = {}
Dead = {}
Alive = {}

end

local function Check ()
	Status = "InProgess"
	if GivenPoints== true then
		return
	end
	for i = 1, #Finshed  do
		CalulateTickets(i)
	end	
end

local function AddPlayersToAliveTabel()
	Status = "InProgess"
	local AmoutPutIn = 0
	for i, plr in ipairs(game.Players:GetPlayers()) do
		table.insert(Alive,plr.UserId)
		AmoutPutIn += 1
		plr:AddTag("InGame")
	end
	return
end



function RoundSerivce.StartTime(Player: Player)
	task.wait(2)
	
	local Count2 = Count()
	if Count2 >= LeastPlayers then
		if Status == "InProgess"  and isfirstround == true  then return end
	isfirstround = false
		RoundHASStarted = true
		RoundStarting:FireAllClients(SI,2)
		RemoveUserid()
		while TimeWaiting ~= IntermissonTime do
			local NewCount = Count()
			if NewCount < LeastPlayers then
				RoundHASStarted = false
				RoundStarting:FireAllClients(NEP,"2")
				break
			end
			TimeWaiting += 1
			task.wait(1)
		end
		
		Round += 1
		print(Round)
		TimeWaiting = 1
		TPPlayers(TeleportationPart)
		AddPlayersToAliveTabel()
			workspace.Colours:SetAttribute("Round",Round)
		Status = "InProgess"
		InGame(Player)
		for i = 1,Roatation do
			if Check2(Alive) == 0 then
				GivenPoints = true
				print("G2")
				for i = 1, #Finshed  do
					CalulateTickets(i)
				end
				break
				end
			ColourPickerSerivce.Run()
			task.wait(3)
		end
		workspace.Baseplate:SetAttribute("OutOfPlayers",true)
	TPPlayers(workspace.SpawnLocation)
	Check()
	GivenPoints = false
		
print("Restarting Round")			
	else 
	print( "Not Enough Players!")
	end
end

function RoundSerivce.Stuff()
	if workspace.Baseplate:GetAttribute("OutOfPlayers") == true then
		print(Status)
		if Status == "Intermisson" then 
			workspace.Baseplate:SetAttribute("OutOfPlayers",false) 
			return
		end
		workspace.Baseplate:SetAttribute("OutOfPlayers",false) 
		Status = "Intermisson"
		RoundSerivce.StartTime()
		for i,v in game.Players:GetPlayers() do
			if v:HasTag("InGame") then
				v:RemoveTag("InGame")
			end
		end
	end
end

-- Client --

function RoundSerivce.ClentSide(Message,Type)
	local Player = game:GetService("Players").LocalPlayer
	if typeof(Type) == "number" then
		for i = IntermissonTime,1,-1 do
			Player.PlayerGui.Main.Countdown2.Text = Message..i
			task.wait(1)
		end
		Player.PlayerGui.Main.Countdown2.Text = "Round In Progress!"

	elseif typeof(Type) == "string" then
		Player.PlayerGui.Main.Countdown2.Text = Message

	
	end
end




-- Made By MrNobodyDev

return RoundSerivce