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(R)local x=math.acos(R:Dot(Vector3.new(1,0,0)))local K=math.acos(R:Dot(Vector3.new(0,0,-1)))return x*(K>math.pi/2 and-1 or 1)end function Functions.Clamp(R,x,K)return math.max(math.min(K,R),x)end function Functions.GetPercentage(R,x,K)return((K-R)/(x-R))*100 end function Functions.Round(R,x)local K,I=math.modf(R)return I>=x and math.ceil(R)or I<x and math.floor(R)end function Functions.IsTeamMate(R,x)return R and(x and(not R.Neutral and(not x.Neutral and R.TeamColor==x.TeamColor)))end function Functions.TagHumanoid(R,x)local K=(Create("\079\098\106\101\099\116\086\097\108\117\101"))({Name="\099\114\101\097\116\111\114";Value=x})Debris:AddItem(K,2)K.Parent=R end function Functions.UntagHumanoid(R)for R,x in pairs(R:GetChildren())do if x:IsA("\079\098\106\101\099\116\086\097\108\117\101")and x.Name=="\099\114\101\097\116\111\114"then x:Destroy()end end end function Functions.CheckTableForString(R,x)for R,K in pairs(R)do if string.find(string.lower(x),string.lower(K))then return true end end return false end function Functions.CheckIntangible(R)local x={"\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 R and R.Parent then if(not R.CanCollide or R.Parent:IsA("\072\097\116")or Functions.CheckTableForString(x,R.Name))and not R.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")then return true end end return false end function Functions.CastRay(R,x,K,I,t)local U=type(I)=="\116\097\098\108\101"and I or{I}local d,A,h=(game:GetService("\087\111\114\107\115\112\097\099\101")):FindPartOnRayWithIgnoreList(Ray.new(R,x*K),U)if d and Functions.CheckIntangible(d)then if t then wait()end d,A,h=Functions.CastRay(A+x*.01,x,K-(R-A).magnitude,U,t)end return d,A,h end function Functions.CheckTableForInstance(R,x)for R,K in pairs(R)do if K==x then return true end end return false end function Functions.GetAllConnectedParts(R)local x={}local function K(R)for R,I in pairs(R:GetConnectedParts())do local t=false if not Functions.CheckTableForInstance(x,I)then table.insert(x,I)K(I)end end end K(R)return x end function GetTotalParts(R,x,K)if R<x then return R elseif K>=R then return 0 elseif R>=x then local I=R-x if K<=R then I=R-K if I>x then return x else return I end elseif I>=x then return x else return I end end end function Functions.GetParts(R,x,K)local I={}local t=false while#I<x and not t do local U=R local d=GetTotalParts(x,100,#I)local A=(game:GetService("\087\111\114\107\115\112\097\099\101")):FindPartsInRegion3WithIgnoreList(U,K,d)if#A==0 then t=true else for R,x in pairs(A)do table.insert(I,x)table.insert(K,x)end end end return I end return Functions
--Made by Luckymaxer

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
