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

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

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

Functions = {}

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
