Roblox/luau_corpus huggingface dataset:
--[[ The Module ]]--
local BaseOcclusion = require(script.Parent:WaitForChild("BaseOcclusion"))
local Invisicam = setmetatable({}, BaseOcclusion)
Invisicam.__index = Invisicam

function Invisicam.new()
	local self = setmetatable(BaseOcclusion.new(), Invisicam)
	
	self.char = nil
	self.humanoidRootPart = nil
	self.torsoPart = nil
	self.headPart = nil
	
	self.childAddedConn = nil
	self.childRemovedConn = nil
	
	self.behaviors = {} 	-- Map of modes to behavior fns
	self.behaviors[MODE.LIMBS] = self.LimbBehavior
	self.behaviors[MODE.MOVEMENT] = self.MoveBehavior
	self.behaviors[MODE.CORNERS] = self.CornerBehavior
	self.behaviors[MODE.CIRCLE1] = self.CircleBehavior
	self.behaviors[MODE.CIRCLE2] = self.CircleBehavior
	self.behaviors[MODE.LIMBMOVE] = self.LimbMoveBehavior
	self.behaviors[MODE.SMART_CIRCLE] = self.SmartCircleBehavior
	self.behaviors[MODE.CHAR_OUTLINE] = self.CharacterOutlineBehavior	
	
	self.mode = MODE.SMART_CIRCLE
	self.behaviorFunction = self.SmartCircleBehavior
	
	
	self.savedHits = {} 	-- Objects currently being faded in/out
	self.trackedLimbs = {}	-- Used in limb-tracking casting modes
		
	self.camera = game.Workspace.CurrentCamera

	self.enabled = false
	return self
end

function Invisicam:Enable(enable)
	self.enabled = enable
	
	if not enable then
		self:Cleanup()
	end
end

function Invisicam:GetOcclusionMode()
	return Enum.DevCameraOcclusionMode.Invisicam
end
-- Initialize mesh tool
local MeshTool = require(CoreTools:WaitForChild 'Mesh')
Core.AssignHotkey('H', Core.Support.Call(Core.EquipTool, MeshTool));
Core.Dock.AddToolButton(Core.Assets.MeshIcon, 'H', MeshTool, 'MeshInfo');
--Returns the character and humanoid of a descendants.
local function FindCharacterAncestor(Ins)
	if Ins and Ins ~= game.Workspace then
		local Humanoid = Ins:FindFirstChildOfClass("Humanoid")
		if Humanoid then
			return Ins,Humanoid
		else
			return FindCharacterAncestor(Ins.Parent)
		end
	end
end
--------------------) Settings
Damage = 0 -- the ammout of health the player or mob will take

Cooldown = 1 -- cooldown for use of the tool again

ZoneModelName = "Insanity Bone rise" -- name the zone model

MobHumanoidName = "Humanoid"-- the name of player or mob u want to damage
--[=[
	@class Input

	The Input module provides access to various user input classes.

	- [PreferredInput](/api/PreferredInput)
	- [Mouse](/api/Mouse)
	- [Keyboard](/api/Keyboard)
	- [Touch](/api/Touch)

	```lua
	local Input = require(packages.Input)

	local PreferredInput = Input.PreferredInput
	local Mouse = Input.Mouse
	local Keyboard = Input.Keyboard
	local Touch = Input.Touch
	```
]=]
local Input = {
	PreferredInput = require(script.PreferredInput);
	Mouse = require(script.Mouse);
	Keyboard = require(script.Keyboard);
	Touch = require(script.Touch);
}

return Input
--input experince values, output level

local ExperienceCalculator = {}
local ExperienceFactor = 10

local function GetLevelFromExperience(Experience)
	-- http://stackoverflow.com/questions/6954874/php-game-formula-to-calculate-a-level-based-on-exp
	
	return math.floor((ExperienceFactor + math.sqrt(ExperienceFactor * ExperienceFactor - 4 * ExperienceFactor * (-Experience)))/ (2 * ExperienceFactor))
end
ExperienceCalculator.GetLevelFromExperience = GetLevelFromExperience

local function GetExperienceForNextLevel(CurrentExperience)
	if CurrentExperience - 1 == CurrentExperience then -- Math.huge
		return 0
	end
	
	local CurrentLevel = GetLevelFromExperience(CurrentExperience)
	local ExperienceRequired = ExperienceFactor*(CurrentLevel*(1+CurrentLevel))
	--local ExperienceRequiredForCurrentLevel = ExperienceFactor*(CurrentLevel*(1+CurrentLevel))

	local ExperienceLeft = ExperienceRequired - CurrentExperience
	
	return ExperienceLeft
end
ExperienceCalculator.GetExperienceForNextLevel = GetExperienceForNextLevel



local function GetExperienceRequiredForLevel(Level)
	Level = Level - 1 -- Because normally this formula calculates experience required for next level.
	return ExperienceFactor*(Level*(1+Level))
end

ExperienceCalculator.GetExperienceRequiredForLevel = GetExperienceRequiredForLevel


local function GetSubExperience(CurrentExperience)
	-- @return Achieved of next level, Total required for next level, Percent
	
	if CurrentExperience - 1 == CurrentExperience then -- Math.huge
		return 1,1,1
	end
	
	local CurrentLevel = GetLevelFromExperience(CurrentExperience)
	local LastLevel = CurrentLevel-1
	
	local ExperienceRequiredForCurrentLevel = ExperienceFactor*(LastLevel*(1+LastLevel))
	local ExperienceRequired = ExperienceFactor*(CurrentLevel*(1+CurrentLevel))
	

	
	local AchievedOfNext = CurrentExperience - ExperienceRequiredForCurrentLevel 
	local SubTotalRequired = ExperienceRequired - ExperienceRequiredForCurrentLevel
	local Percent = AchievedOfNext/SubTotalRequired
	
	return AchievedOfNext, SubTotalRequired, Percent
end
ExperienceCalculator.GetSubExperience = GetSubExperience

return ExperienceCalculator
-- The maximum distance the can can shoot, this value should never go above 1000
local Range = 1000
--Precalculated paths
local t,f,n=true,false,{}
local r={
[58]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58},t},
[49]={{48,49},t},
[16]={n,f},
[19]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,20,19},t},
[59]={{48,49,45,44,28,29,31,32,34,35,39,41,59},t},
[63]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,23,62,63},t},
[34]={{48,49,45,44,28,29,31,32,34},t},
[21]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,20,21},t},
[48]={{48},t},
[27]={{48,49,45,44,28,27},t},
[14]={n,f},
[31]={{48,49,45,44,28,29,31},t},
[56]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56},t},
[29]={{48,49,45,44,28,29},t},
[13]={n,f},
[47]={{48,47},t},
[12]={n,f},
[45]={{48,49,45},t},
[57]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,57},t},
[36]={{48,49,45,44,28,29,31,32,33,36},t},
[25]={{48,49,45,44,28,27,26,25},t},
[71]={{48,49,45,44,28,29,31,32,34,35,39,41,59,61,71},t},
[20]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,20},t},
[60]={{48,49,45,44,28,29,31,32,34,35,39,41,60},t},
[8]={n,f},
[4]={n,f},
[75]={{48,49,45,44,28,29,31,32,34,35,39,41,59,61,71,72,76,73,75},t},
[22]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,20,21,22},t},
[74]={{48,49,45,44,28,29,31,32,34,35,39,41,59,61,71,72,76,73,74},t},
[62]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,23,62},t},
[1]={n,f},
[6]={n,f},
[11]={n,f},
[15]={n,f},
[37]={{48,49,45,44,28,29,31,32,33,36,37},t},
[2]={n,f},
[35]={{48,49,45,44,28,29,31,32,34,35},t},
[53]={{48,47,52,53},t},
[73]={{48,49,45,44,28,29,31,32,34,35,39,41,59,61,71,72,76,73},t},
[72]={{48,49,45,44,28,29,31,32,34,35,39,41,59,61,71,72},t},
[33]={{48,49,45,44,28,29,31,32,33},t},
[69]={{48,49,45,44,28,29,31,32,34,35,39,41,60,69},t},
[65]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,20,19,66,64,65},t},
[26]={{48,49,45,44,28,27,26},t},
[68]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,20,19,66,64,67,68},t},
[76]={{48,49,45,44,28,29,31,32,34,35,39,41,59,61,71,72,76},t},
[50]={{48,47,50},t},
[66]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,20,19,66},t},
[10]={n,f},
[24]={{48,49,45,44,28,27,26,25,24},t},
[23]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,23},t},
[44]={{48,49,45,44},t},
[39]={{48,49,45,44,28,29,31,32,34,35,39},t},
[32]={{48,49,45,44,28,29,31,32},t},
[3]={n,f},
[30]={{48,49,45,44,28,29,31,32,34,35,39,41,30},t},
[51]={{48,47,50,51},t},
[18]={n,f},
[67]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,20,19,66,64,67},t},
[61]={{48,49,45,44,28,29,31,32,34,35,39,41,59,61},t},
[55]={{48,47,52,53,54,55},t},
[46]={{48,47,46},t},
[42]={{48,49,45,44,28,29,31,32,34,35,38,42},t},
[40]={{48,49,45,44,28,29,31,32,34,35,40},t},
[52]={{48,47,52},t},
[54]={{48,47,52,53,54},t},
[43]={n,f},
[7]={n,f},
[9]={n,f},
[41]={{48,49,45,44,28,29,31,32,34,35,39,41},t},
[17]={n,f},
[38]={{48,49,45,44,28,29,31,32,34,35,38},t},
[28]={{48,49,45,44,28},t},
[5]={n,f},
[64]={{48,49,45,44,28,29,31,32,34,35,39,41,30,56,58,20,19,66,64},t},
}
return r
--[=[
	Utils that work with Roblox Value objects (and also ValueObject)
	@class ValueObjectUtils
]=]

local require = require(script.Parent.loader).load(script)

local Maid = require("Maid")
local Brio = require("Brio")
local Observable = require("Observable")
local ValueObject = require("ValueObject")

local ValueObjectUtils = {}
-- Don't set this above 1, it will cause glitchy behaviour.
local UpdateSpeed = 0.3 -- How fast the body will rotates.
local UpdateDelay = 0.05 -- How fast the heartbeat will update.
--- Runs embedded commands and replaces them
function Util.RunEmbeddedCommands(dispatcher, str)
	str = encodeCommandEscape(str)

	local results = {}
	-- We need to do this because you can't yield in the gsub function
	for text in str:gmatch("$(%b{})") do
		local doQuotes = true
		local commandString = text:sub(2, #text-1)

		if commandString:match("^{.+}$") then -- Allow double curly for literal replacement
			doQuotes = false
			commandString = commandString:sub(2, #commandString-1)
		end

		results[text] = dispatcher:EvaluateAndRun(commandString)

		if doQuotes and results[text]:find("%s") then
			results[text] = string.format("%q", results[text])
		end
	end

	return decodeCommandEscape(str:gsub("$(%b{})", results))
end
--// SS3 controls for AC6 by Itzt, originally for 2014 Infiniti QX80. i don't know how to tune ac lol
 
wait(0.1)
local player = game.Players.LocalPlayer
local HUB = script.Parent.HUB
local TR = script.Parent.Tracker
local INFO = script.Parent.Infotainment
local limitButton = HUB.Name
local lightOn = false
local Camera = game.Workspace.CurrentCamera
local cam = script.Parent.nxtcam.Value
local infomode = script.Parent.infotain.Value
local carSeat = script.Parent.CarSeat.Value
local mouse = game.Players.LocalPlayer:GetMouse()
local windows = false
local winfob = HUB.Parent.Windows
--Made by Luckymaxer

Model = script.Parent

Creator = Model:FindFirstChild("Creator")

Enabled = false

if Creator and Creator.Value and Creator.Value.Parent and Creator.Value:IsA("Player") and Creator.Value.Character then
	Player = Creator.Value
	Character = Player.Character
	Humanoid = Character:FindFirstChild("Humanoid")
	if Humanoid and Humanoid.Health > 0 then
		Player.Changed:connect(function(Property)
			if Property == "Parent" and not Player.Parent then
				Model:Destroy()
			end
		end)
		Character.Changed:connect(function(Property)
			if Property == "Parent" and not Character.Parent then
				Model:Destroy()
			end
		end)
		Humanoid.Died:connect(function()
			Model:Destroy()
		end)
		Enabled = true
	end
end

if not Enabled then
	Model:Destroy()
end
--- Creates or finds a hitbox object. Returns an hitbox object
-- @param required object parameter that takes in either a part or a model
function RaycastHitbox.new(object: any?)
	local hitbox: any

	if object and CollectionService:HasTag(object, DEFAULT_COLLECTION_TAG_NAME) then
		hitbox = HitboxData:_FindHitbox(object)
	else
		hitbox = setmetatable({
			RaycastParams = nil,
			DetectionMode = RaycastHitbox.DetectionMode.Default,
			HitboxRaycastPoints = {},
			HitboxPendingRemoval = false,
			HitboxStopTime = 0,
			HitboxObject = object,
			HitboxHitList = {},
			HitboxActive = false,
			Visualizer = SHOW_DEBUG_RAY_LINES,
			DebugLog = SHOW_OUTPUT_MESSAGES,
			SignalType = RaycastHitbox.SignalType.Single,
			OnUpdate = Signal.new(RaycastHitbox.SignalType.Single),
			OnHit = Signal.new(RaycastHitbox.SignalType.Single),
			Tag = DEFAULT_COLLECTION_TAG_NAME,
		}, HitboxData)

		hitbox:_Init()
	end

	return hitbox
end
--[[script.Parent.Examinar.MouseButton1Down:connect(function()
	if Saude.Variaveis.Doer.Value == false and script.Parent.Parent.ExaminarAberto.Visible == false then
	Saude.Variaveis.Doer.Value = true
	Timer.Barra.Size = UDim2.new(0,0,1,0)
	TS:Create(Timer.Barra, TweenInfo.new(5), {Size =  UDim2.new(1,0,1,0)}):Play()
	wait(5)
	script.Parent.Parent.ExaminarAberto.Visible = true
	script.Parent.Parent.ExaminarAberto.Base.DiagnoseHandler.Disabled = false
	Saude.Variaveis.Doer.Value = false
	end
end)]]


script.Parent.Bandages.MouseButton1Down:connect(function()
	if Saude.Variaveis.Doer.Value == false and script.Parent.Parent.BandagesAberto.Visible == false then
	--Saude.Variaveis.Doer.Value = true
	--Timer.Barra.Size = UDim2.new(0,0,1,0)
	--TS:Create(Timer.Barra, TweenInfo.new(.25), {Size =  UDim2.new(1,0,1,0)}):Play()
	--wait(.25)
	script.Parent.Parent.OtherAberto.Visible = false
	script.Parent.Parent.MedicineAberto.Visible = false
	script.Parent.Parent.BandagesAberto.Visible = true
	--Saude.Variaveis.Doer.Value = false
	end
end)

script.Parent.Medicines.MouseButton1Down:connect(function()
	if Saude.Variaveis.Doer.Value == false and script.Parent.Parent.MedicineAberto.Visible == false then
	--Saude.Variaveis.Doer.Value = true
	--Timer.Barra.Size = UDim2.new(0,0,1,0)
	--TS:Create(Timer.Barra, TweenInfo.new(.25), {Size =  UDim2.new(1,0,1,0)}):Play()
	--wait(.25)
	script.Parent.Parent.OtherAberto.Visible = false
	script.Parent.Parent.MedicineAberto.Visible = true
	script.Parent.Parent.BandagesAberto.Visible = false
	--Saude.Variaveis.Doer.Value = false
	end
end)

script.Parent.Others.MouseButton1Down:connect(function()
	if Saude.Variaveis.Doer.Value == false and script.Parent.Parent.OtherAberto.Visible == false then
	--Saude.Variaveis.Doer.Value = true
	--Timer.Barra.Size = UDim2.new(0,0,1,0)
	--TS:Create(Timer.Barra, TweenInfo.new(.25), {Size =  UDim2.new(1,0,1,0)}):Play()
	--wait(.25)
	script.Parent.Parent.OtherAberto.Visible = true
	script.Parent.Parent.MedicineAberto.Visible = false
	script.Parent.Parent.BandagesAberto.Visible = false
	--Saude.Variaveis.Doer.Value = false
	end
end)
--[[ Local functionality ]]--

local function isDynamicThumbstickEnabled()
	return ThumbstickFrame and ThumbstickFrame.Visible
end

local function enableAutoJump(humanoid)
	if humanoid and isDynamicThumbstickEnabled() then
		local shouldRevert = humanoid.AutoJumpEnabled == false
		shouldRevert = shouldRevert and LocalPlayer.DevTouchMovementMode == Enum.DevTouchMovementMode.UserChoice
		RevertAutoJumpEnabledToFalse = shouldRevert
		humanoid.AutoJumpEnabled = true
	end
end

do
	local function onCharacterAdded(character)	
		for _, child in ipairs(LocalPlayer.Character:GetChildren()) do
			if child:IsA("Tool") then
				ToolEquipped = child
			end
		end
		character.ChildAdded:Connect(function(child)
			if child:IsA("Tool") then
				ToolEquipped = child
			elseif child:IsA("Humanoid") then
				enableAutoJump(child)
			end
		end)
		character.ChildRemoved:Connect(function(child)
			if child:IsA("Tool") then
				if child == ToolEquipped then
					ToolEquipped = nil
				end
			end
		end)
		
		local humanoid = character:FindFirstChildOfClass("Humanoid")
		if humanoid then
			enableAutoJump(humanoid)
		end
	end
	LocalPlayer.CharacterAdded:Connect(onCharacterAdded)
	if LocalPlayer.Character then
		onCharacterAdded(LocalPlayer.Character)
	end
end
-- REMOTES --
local SkillsHandler = Remotes:WaitForChild("Attack")
--Variables----------
local random = Random.new(tick())
local ChangeSize = ReplicatedStorage.Signals.Functions.ChangeSize
local X, Y, Z
--[=[
	Returns true if a number is NaN
	@param num number
	@return boolean
]=]
function Math.isNaN(num: number): boolean
   return num ~= num
end
---NinjaStorm21
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = 'rbxassetid:// 68308747'    ----Change ID to any decal, Be sure to minus 1 digit from the last digit
--[[[Default Controls]]
	--Peripheral Deadzones
	Tune.Peripherals = {
		MSteerWidth				= 67		,	-- Mouse steering control width	(0 - 100% of screen width)
		MSteerDZone				= 10		,	-- Mouse steering deadzone (0 - 100%)
		
		ControlLDZone			= 5			,	-- Controller steering L-deadzone (0 - 100%)
		ControlRDZone			= 5			,	-- Controller steering R-deadzone (0 - 100%)
	}
	
	--Control Mapping
	Tune.Controls = {
		
	--Keyboard Controls
		--Mode Toggles
		ToggleTCS				= Enum.KeyCode.T					,
		ToggleABS				= Enum.KeyCode.Y					,
		ToggleTransMode			= Enum.KeyCode.M					,
		
		
		--Primary Controls
		Throttle				= Enum.KeyCode.Up					,
		Brake					= Enum.KeyCode.Down					,
		SteerLeft				= Enum.KeyCode.Left					,
		SteerRight				= Enum.KeyCode.Right				,
		
		--Secondary Controls
		Throttle2				= Enum.KeyCode.W					,
		Brake2					= Enum.KeyCode.S					,
		SteerLeft2				= Enum.KeyCode.A					,
		SteerRight2				= Enum.KeyCode.D					,
		
		--Manual Transmission
		ShiftUp					= Enum.KeyCode.E					,
		ShiftDown				= Enum.KeyCode.Q					,
		Clutch					= Enum.KeyCode.LeftShift			,
		
		--Handbrake
		PBrake					= Enum.KeyCode.P					,
		
	--Mouse Controls
		MouseThrottle			= Enum.UserInputType.MouseButton1	,
		MouseBrake				= Enum.UserInputType.MouseButton2	,
		MouseClutch				= Enum.KeyCode.W					,
		MouseShiftUp			= Enum.KeyCode.E					,
		MouseShiftDown			= Enum.KeyCode.Q					,
		MousePBrake				= Enum.KeyCode.LeftShift			,
		
	--Controller Mapping
		ContlrThrottle			= Enum.KeyCode.ButtonR2				,
		ContlrBrake				= Enum.KeyCode.ButtonL2				,
		ContlrSteer				= Enum.KeyCode.Thumbstick1			,
		ContlrShiftUp			= Enum.KeyCode.ButtonY				,
		ContlrShiftDown			= Enum.KeyCode.ButtonX				,
		ContlrClutch			= Enum.KeyCode.ButtonR1				,
		ContlrPBrake			= Enum.KeyCode.ButtonL1				,
		ContlrToggleTMode		= Enum.KeyCode.DPadUp				,
		ContlrToggleTCS			= Enum.KeyCode.DPadDown				,
		ContlrToggleABS			= Enum.KeyCode.DPadRight			,
	}
--[=[
	@interface Controller
	.Name string
	.[any] any
	@within KnitClient
]=]
type Controller = {
	Name: string,
	[any]: any,
}
--[=[
	Same as `andThenCall`, except for `done`.

	Attaches a `done` handler to this Promise that calls the given callback with the predefined arguments.

	@param callback (...: any) -> any
	@param ...? any -- Additional arguments which will be passed to `callback`
	@return Promise
]=]
function Promise.prototype:doneCall(callback, ...)
	assert(isCallable(callback), string.format(ERROR_NON_FUNCTION, "Promise:doneCall"))
	local length, values = pack(...)
	return self:_finally(debug.traceback(nil, 2), function()
		return callback(unpack(values, 1, length))
	end, true)
end
--s.Pitch = 0.7
while s.Pitch<0.901 do
s.Pitch=s.Pitch+0.010
s:Play()
if s.Pitch>0.901 then
	s.Pitch=0.901
end
wait(0.001)
end
-- enable the viewmodel system
local function enableviewmodel()
	isfirstperson = true
	viewmodel.Parent = workspace.CurrentCamera
	if rigtype == "R15" then
		-- disable character joints, enable viewmodel joints
		rightshoulderclone.Enabled = true
		leftshoulderclone.Enabled = true
		-- disable real shoulders
		leftshoulder.Enabled = false
		rightshoulder.Enabled = false
		--
		rightshoulderclone.Part1 = rarm
		rightshoulderclone.Part0 = faketorso
		rightshoulderclone.Parent = faketorso
		--
		leftshoulderclone.Part1 = larm
		leftshoulderclone.Part0 = faketorso
		leftshoulderclone.Parent = faketorso
		--
		armtransparency = firstperson_arm_transparency
	else
		--
		rightshoulderclone.Enabled = true
		leftshoulderclone.Enabled = true
		-- disable real shoulders
		leftshoulder.Enabled = false
		rightshoulder.Enabled = false
		--
		rightshoulderclone.Part1 = rarm
		rightshoulderclone.Part0 = faketorso
		rightshoulderclone.Parent = faketorso
		--
		leftshoulderclone.Part1 = larm
		leftshoulderclone.Part0 = faketorso
		leftshoulderclone.Parent = faketorso
		--
		armtransparency = firstperson_arm_transparency
	end
end
--		print("Keyframe : ".. frameName)	
		playToolAnimation(toolAnimName, 0.0, Enemy)
	end
end


function playToolAnimation(animName, transitionTime, humanoid)	 
		
		local roll = math.random(1, animTable[animName].totalWeight) 
		local origRoll = roll
		local idx = 1
		while (roll > animTable[animName][idx].weight) do
			roll = roll - animTable[animName][idx].weight
			idx = idx + 1
		end
-- Created by Sedhorn

local team = script.Parent.Team
local frame = script.Parent.Parent
local player = game.Players.LocalPlayer



script.Parent.MouseButton1Click:connect(function()
	frame.Visible = false
		player.Team = team.Value
		
end)
-- Public Functions

function TeamManager:ClearTeamScores()
	for _, team in ipairs(Teams:GetTeams()) do
		TeamScores[team] = 0
		DisplayManager:UpdateScore(team, 0)
	end
end

function TeamManager:HasTeamWon()
	for _, team in ipairs(Teams:GetTeams()) do
		if TeamScores[team] >= Configurations.MainGameConfig["Captures To Win"] then
			return team
		end
	end
	return false
end

function TeamManager:GetWinningTeam()
	local highestScore = 0
	local winningTeam = nil
	for _, team in ipairs(Teams:GetTeams()) do
		if TeamScores[team] > highestScore then
			highestScore = TeamScores[team]
			winningTeam = team
			for i, winningPlayer in ipairs(TeamPlayers[winningTeam]) do
				winningPlayer.leaderstats.Cash.Value += 100
			end
		end
	end
	return winningTeam
end

function TeamManager:AreTeamsTied()
	local teams = Teams:GetTeams()
	local highestScore = 0
	local tied = false
	for _, team in ipairs(teams) do
		if TeamScores[team] == highestScore then
			tied = true
		elseif TeamScores[team] > highestScore then
			tied = false
			highestScore = TeamScores[team]
		end
	end
	return tied
end

function TeamManager:AssignPlayerToTeam(player)
	local smallestTeam
	local lowestCount = math.huge
	for team, playerList in pairs(TeamPlayers) do
		if #playerList < lowestCount then
			smallestTeam = team
			lowestCount = #playerList
		end
	end
	table.insert(TeamPlayers[smallestTeam], player)
	player.Neutral = false
	player.TeamColor = smallestTeam.TeamColor
end

function TeamManager:RemovePlayer(player)
	local team = GetTeamFromColor(player.TeamColor)
	local teamTable = TeamPlayers[team]
	for i = 1, #teamTable do
		if teamTable[i] == player then
			table.remove(teamTable, i)
			return
		end
	end
end

function TeamManager:ShuffleTeams()
	for _, team in ipairs(Teams:GetTeams()) do
		TeamPlayers[team] = {}
	end
	local players = Players:GetPlayers()
	while #players > 0 do
		local rIndex = math.random(1, #players)
		local player = table.remove(players, rIndex)
		TeamManager:AssignPlayerToTeam(player)
	end
end

function TeamManager:AddTeamScore(teamColor, score)
	local team = GetTeamFromColor(teamColor)
	TeamScores[team] = TeamScores[team] + score
	DisplayManager:UpdateScore(team, TeamScores[team])
end

return TeamManager
-- How long a player can float around before the anticheat overheats.
config.MaxFlyingDuration = 1.2
--[[
	Constructs a new ForPairs object which maps pairs of a table using
	a `processor` function.

	Optionally, a `destructor` function can be specified for cleaning up values.
	If omitted, the default cleanup function will be used instead.

	Additionally, a `meta` table/value can optionally be returned to pass data created
	when running the processor to the destructor when the created object is cleaned up.
]]

local Dependencies = require(script.Parent.Parent.Dependencies)
local utility = Dependencies.utility

local class = {}

local CLASS_METATABLE = { __index = class }
-- Removes `i` from `t`. Also sets `Index` field in removed value.
local function remove(t,i)
	local v = t[i]
	for n = i+1,#t do
		local v = t[n]
		v.Index = n-1
		t[n-1] = v
	end
	t[#t] = nil
	v.Index = 0
	return v
end