Players=game:GetService("\080\108\097\121\101\114\115")Debris=game:GetService("\068\101\098\114\105\115")RbxUtility=LoadLibrary("\082\098\120\085\116\105\108\105\116\121")Create=RbxUtility.Create Functions={}function Functions.GetAngle(j)local H=math.acos(j:Dot(Vector3.new(1,0,0)))local p=math.acos(j:Dot(Vector3.new(0,0,-1)))return H*(p>math.pi/2 and-1 or 1)end function Functions.Clamp(j,H,p)return math.max(math.min(p,j),H)end function Functions.GetPercentage(j,H,p)return((p-j)/(H-j))*100 end function Functions.Round(j,H)local p,e=math.modf(j)return e>=H and math.ceil(j)or e<H and math.floor(j)end function Functions.IsTeamMate(j,H)return j and(H and(not j.Neutral and(not H.Neutral and j.TeamColor==H.TeamColor)))end function Functions.TagHumanoid(j,H)local p=(Create("\079\098\106\101\099\116\086\097\108\117\101"))({Name="\099\114\101\097\116\111\114";Value=H})Debris:AddItem(p,2)p.Parent=j end function Functions.UntagHumanoid(j)for j,H in pairs(j:GetChildren())do if H:IsA("\079\098\106\101\099\116\086\097\108\117\101")and H.Name=="\099\114\101\097\116\111\114"then H:Destroy()end end end function Functions.CheckTableForString(j,H)for j,p in pairs(j)do if string.find(string.lower(H),string.lower(p))then return true end end return false end function Functions.CheckIntangible(j)local H={"\087\097\116\101\114";"\065\114\114\111\119";"\080\114\111\106\101\099\116\105\108\101";"\069\102\102\101\099\116","\082\097\105\108";"\076\097\115\101\114","\066\117\108\108\101\116"}if j and j.Parent then if(not j.CanCollide or j.Parent:IsA("\072\097\116")or Functions.CheckTableForString(H,j.Name))and not j.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")then return true end end return false end function Functions.CastRay(j,H,p,e,A)local M=type(e)=="\116\097\098\108\101"and e or{e}local G,n,q=(game:GetService("\087\111\114\107\115\112\097\099\101")):FindPartOnRayWithIgnoreList(Ray.new(j,H*p),M)if G and Functions.CheckIntangible(G)then if A then wait()end G,n,q=Functions.CastRay(n+H*.01,H,p-(j-n).magnitude,M,A)end return G,n,q end function Functions.CheckTableForInstance(j,H)for j,p in pairs(j)do if p==H then return true end end return false end function Functions.GetAllConnectedParts(j)local H={}local function p(j)for j,e in pairs(j:GetConnectedParts())do local A=false if not Functions.CheckTableForInstance(H,e)then table.insert(H,e)p(e)end end end p(j)return H end function GetTotalParts(j,H,p)if j<H then return j elseif p>=j then return 0 elseif j>=H then local e=j-H if p<=j then e=j-p if e>H then return H else return e end elseif e>=H then return H else return e end end end function Functions.GetParts(j,H,p)local e={}local A=false while#e<H and not A do local M=j local G=GetTotalParts(H,100,#e)local n=(game:GetService("\087\111\114\107\115\112\097\099\101")):FindPartsInRegion3WithIgnoreList(M,p,G)if#n==0 then A=true else for j,H in pairs(n)do table.insert(e,H)table.insert(p,H)end end end return e end return Functions


Players = game:GetService("Players")
Debris = game:GetService("Debris")

RbxUtility = LoadLibrary("RbxUtility")
Create = RbxUtility.Create

Functions = {}

function Functions.GetAngle(Direction)
    local Angle = math.acos(Direction:Dot(Vector3.new(1, 0, 0)))
    local Modifier = math.acos(Direction:Dot(Vector3.new(0, 0, -1)))
    return (Angle * (Modifier > (math.pi / 2) and -1 or 1))
end

function Functions.Clamp(Number, Min, Max)
	return math.max(math.min(Max, Number), Min)
end

function Functions.GetPercentage(Start, End, Number)
	return (((Number - Start) / (End - Start)) * 100)
end

function Functions.Round(Number, RoundDecimal)
	local WholeNumber, Decimal = math.modf(Number)
	return ((Decimal >= RoundDecimal and math.ceil(Number)) or (Decimal < RoundDecimal and math.floor(Number)))
end

function Functions.IsTeamMate(Player1, Player2)
	return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
end

function Functions.TagHumanoid(humanoid, player)
	local Creator_Tag = Create("ObjectValue"){
		Name = "creator",
		Value = player,
	}
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

function Functions.UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			v:Destroy()
		end
	end
end

function Functions.CheckTableForString(Table, String)
	for i, v in pairs(Table) do
		if string.find(string.lower(String), string.lower(v)) then
			return true
		end
	end
	return false
end

function Functions.CheckIntangible(Hit)
	local ProjectileNames = {"Water", "Arrow", "Projectile", "Effect", "Rail", "Laser", "Bullet"}
	if Hit and Hit.Parent then
		if ((not Hit.CanCollide or Hit.Parent:IsA("Hat") or Functions.CheckTableForString(ProjectileNames, Hit.Name)) and not Hit.Parent:FindFirstChild("Humanoid")) then
			return true
		end
	end
	return false
end

function Functions.CastRay(StartPos, Vec, Length, Ignore, DelayIfHit)
	local Ignore = ((type(Ignore) == "table" and Ignore) or {Ignore})
	local RayHit, RayPos, RayNormal = game:GetService("Workspace"):FindPartOnRayWithIgnoreList(Ray.new(StartPos, Vec * Length), Ignore)
	if RayHit and Functions.CheckIntangible(RayHit) then
		if DelayIfHit then
			wait()
		end
		RayHit, RayPos, RayNormal = Functions.CastRay((RayPos + (Vec * 0.01)), Vec, (Length - ((StartPos - RayPos).magnitude)), Ignore, DelayIfHit)
	end
	return RayHit, RayPos, RayNormal
end

function Functions.CheckTableForInstance(Table, Instance)
	for i, v in pairs(Table) do
		if v == Instance then
			return true
		end
	end
	return false
end

function Functions.GetAllConnectedParts(Object)
	local Parts = {}
	local function GetConnectedParts(Object)
		for i, v in pairs(Object:GetConnectedParts()) do
			local Ignore = false
			if not Functions.CheckTableForInstance(Parts, v) then
				table.insert(Parts, v)
				GetConnectedParts(v)
			end
		end
	end
	GetConnectedParts(Object)
	return Parts
end
	
function GetTotalParts(MaxParts, PossibleParts, Parts)
	if MaxParts < PossibleParts then
		return MaxParts
	elseif Parts >= MaxParts then
		return 0
	elseif MaxParts >= PossibleParts then
		local PartCount = (MaxParts - PossibleParts)
		if Parts <= MaxParts then
			PartCount = (MaxParts - Parts)
			if PartCount > PossibleParts then
				return PossibleParts
			else
				return PartCount
			end
		elseif PartCount >= PossibleParts then
			return PossibleParts
		else
			return PartCount
		end
	end
end
	
function Functions.GetParts(Region, MaxParts, Ignore)
	local Parts = {}
	local RerunFailed = false
	while #Parts < MaxParts and not RerunFailed do
		local Region = Region
		local PossibleParts = GetTotalParts(MaxParts, 100, #Parts)
		local PartsNearby = game:GetService("Workspace"):FindPartsInRegion3WithIgnoreList(Region, Ignore, PossibleParts)
		if #PartsNearby == 0 then
			RerunFailed = true
		else
			for i, v in pairs(PartsNearby) do
				table.insert(Parts, v)
				table.insert(Ignore, v)
			end
		end
	end
	return Parts
end

return Functions
