local h={}h.__index=h function h.new()local F=setmetatable({},h)F.lastUpdate=tick()F.transparencyDirty=false F.enabled=false F.lastTransparency=nil F.descendantAddedConn=nil F.descendantRemovingConn=nil F.toolDescendantAddedConns={}F.toolDescendantRemovingConns={}F.cachedParts={}return F end function h.HasToolAncestor(h,F)if F.Parent==nil then return false end if F.Parent:IsA("\084\111\111\108")then return true end if F.Parent:IsA("\065\099\099\101\115\115\111\114\121")and string.find(F.Parent.Name,"\070\108\097\115\104\108\105\103\104\116")then return true end return h:HasToolAncestor(F.Parent)end function h.IsValidPartToModify(h,F)if not F:IsA("\066\097\115\101\080\097\114\116")and not F:IsA("\068\101\099\097\108")then return false end return not h:HasToolAncestor(F)end function h.CachePartsRecursive(h,F)if F then if h:IsValidPartToModify(F)then h.cachedParts[F]=true h.transparencyDirty=true end for F,m in pairs(F:GetChildren())do h:CachePartsRecursive(m)end end end function h.TeardownTransparency(h)for h,F in pairs(h.cachedParts)do h.LocalTransparencyModifier=0 end h.cachedParts={}h.transparencyDirty=true h.lastTransparency=nil if h.descendantAddedConn then h.descendantAddedConn:disconnect()h.descendantAddedConn=nil end if h.descendantRemovingConn then h.descendantRemovingConn:disconnect()h.descendantRemovingConn=nil end for F,m in pairs(h.toolDescendantAddedConns)do m:Disconnect()h.toolDescendantAddedConns[F]=nil end for F,m in pairs(h.toolDescendantRemovingConns)do m:Disconnect()h.toolDescendantRemovingConns[F]=nil end end function h.SetupTransparency(h,F)h:TeardownTransparency()if h.descendantAddedConn then h.descendantAddedConn:disconnect()end h.descendantAddedConn=F.DescendantAdded:Connect(function(m)if h:IsValidPartToModify(m)then h.cachedParts[m]=true h.transparencyDirty=true return end if m:IsA("\084\111\111\108")then if h.toolDescendantAddedConns[m]then h.toolDescendantAddedConns[m]:Disconnect()end h.toolDescendantAddedConns[m]=m.DescendantAdded:Connect(function(F)h.cachedParts[F]=nil if F:IsA("\066\097\115\101\080\097\114\116")or F:IsA("\068\101\099\097\108")then F.LocalTransparencyModifier=0 end end)if h.toolDescendantRemovingConns[m]then h.toolDescendantRemovingConns[m]:disconnect()end h.toolDescendantRemovingConns[m]=m.DescendantRemoving:Connect(function(m)wait()if F and(m and(m:IsDescendantOf(F)and h:IsValidPartToModify(m)))then h.cachedParts[m]=true h.transparencyDirty=true end end)end end)if h.descendantRemovingConn then h.descendantRemovingConn:disconnect()end h.descendantRemovingConn=F.DescendantRemoving:connect(function(F)if h.cachedParts[F]then h.cachedParts[F]=nil F.LocalTransparencyModifier=0 end end)h:CachePartsRecursive(F)end function h.Enable(h,F)if h.enabled~=F then h.enabled=F h:Update()end end function h.SetSubject(h,F)local m=nil if F and F:IsA("\072\117\109\097\110\111\105\100")then m=F.Parent end if F and(F:IsA("\086\101\104\105\099\108\101\083\101\097\116")and F.Occupant)then m=F.Occupant.Parent end if not m then h:TeardownTransparency()return end h:SetupTransparency(m)end local F=require(script.Parent:WaitForChild("\067\097\109\101\114\097\085\116\105\108\115"))function h.Update(h)local m=tick()local T=workspace.CurrentCamera if T then local l=0 if h.enabled then local N=(T.Focus.p-T.CoordinateFrame.p).magnitude local a=N<2 and 1-(N-.5)/1.5 or 0 if a<.5 then a=0 end if h.lastTransparency then local T=a-h.lastTransparency if true and(a<1 and h.lastTransparency<.95)then local l=2.8*(m-h.lastUpdate)T=F.Clamp(-l,l,T)end a=h.lastTransparency+T else h.transparencyDirty=true end l=F.Clamp(0,1,F.Round(a,2))end if h.transparencyDirty or h.lastTransparency~=l then for h,F in pairs(h.cachedParts)do h.LocalTransparencyModifier=l end h.transparencyDirty=false h.lastTransparency=l end end h.lastUpdate=m end return h


local v1 = {};
v1.__index = v1;
function v1.new()
	local v2 = setmetatable({}, v1);
	v2.lastUpdate = tick();
	v2.transparencyDirty = false;
	v2.enabled = false;
	v2.lastTransparency = nil;
	v2.descendantAddedConn = nil;
	v2.descendantRemovingConn = nil;
	v2.toolDescendantAddedConns = {};
	v2.toolDescendantRemovingConns = {};
	v2.cachedParts = {};
	return v2;
end;
function v1.HasToolAncestor(p1, p2)
	if p2.Parent == nil then
		return false;
	end;
	if p2.Parent:IsA("Tool") then
		return true;
	end;
	if p2.Parent:IsA("Accessory") and string.find(p2.Parent.Name, "Flashlight") then
		return true;
	end;
	return p1:HasToolAncestor(p2.Parent);
end;
function v1.IsValidPartToModify(p3, p4)
	if not p4:IsA("BasePart") and not p4:IsA("Decal") then
		return false;
	end;
	return not p3:HasToolAncestor(p4);
end;
function v1.CachePartsRecursive(p5, p6)
	if p6 then
		if p5:IsValidPartToModify(p6) then
			p5.cachedParts[p6] = true;
			p5.transparencyDirty = true;
		end;
		for v3, v4 in pairs(p6:GetChildren()) do
			p5:CachePartsRecursive(v4);
		end;
	end;
end;
function v1.TeardownTransparency(p7)
	for v5, v6 in pairs(p7.cachedParts) do
		v5.LocalTransparencyModifier = 0;
	end;
	p7.cachedParts = {};
	p7.transparencyDirty = true;
	p7.lastTransparency = nil;
	if p7.descendantAddedConn then
		p7.descendantAddedConn:disconnect();
		p7.descendantAddedConn = nil;
	end;
	if p7.descendantRemovingConn then
		p7.descendantRemovingConn:disconnect();
		p7.descendantRemovingConn = nil;
	end;
	for v7, v8 in pairs(p7.toolDescendantAddedConns) do
		v8:Disconnect();
		p7.toolDescendantAddedConns[v7] = nil;
	end;
	for v9, v10 in pairs(p7.toolDescendantRemovingConns) do
		v10:Disconnect();
		p7.toolDescendantRemovingConns[v9] = nil;
	end;
end;
function v1.SetupTransparency(p8, p9)
	p8:TeardownTransparency();
	if p8.descendantAddedConn then
		p8.descendantAddedConn:disconnect();
	end;
	p8.descendantAddedConn = p9.DescendantAdded:Connect(function(p10)
		if p8:IsValidPartToModify(p10) then
			p8.cachedParts[p10] = true;
			p8.transparencyDirty = true;
			return;
		end;
		if p10:IsA("Tool") then
			if p8.toolDescendantAddedConns[p10] then
				p8.toolDescendantAddedConns[p10]:Disconnect();
			end;
			p8.toolDescendantAddedConns[p10] = p10.DescendantAdded:Connect(function(p11)
				p8.cachedParts[p11] = nil;
				if p11:IsA("BasePart") or p11:IsA("Decal") then
					p11.LocalTransparencyModifier = 0;
				end;
			end);
			if p8.toolDescendantRemovingConns[p10] then
				p8.toolDescendantRemovingConns[p10]:disconnect();
			end;
			p8.toolDescendantRemovingConns[p10] = p10.DescendantRemoving:Connect(function(p12)
				wait();
				if p9 and p12 and p12:IsDescendantOf(p9) and p8:IsValidPartToModify(p12) then
					p8.cachedParts[p12] = true;
					p8.transparencyDirty = true;
				end;
			end);
		end;
	end);
	if p8.descendantRemovingConn then
		p8.descendantRemovingConn:disconnect();
	end;
	p8.descendantRemovingConn = p9.DescendantRemoving:connect(function(p13)
		if p8.cachedParts[p13] then
			p8.cachedParts[p13] = nil;
			p13.LocalTransparencyModifier = 0;
		end;
	end);
	p8:CachePartsRecursive(p9);
end;
function v1.Enable(p14, p15)
	if p14.enabled ~= p15 then
		p14.enabled = p15;
		p14:Update();
	end;
end;
function v1.SetSubject(p16, p17)
	local v11 = nil;
	if p17 and p17:IsA("Humanoid") then
		v11 = p17.Parent;
	end;
	if p17 and p17:IsA("VehicleSeat") and p17.Occupant then
		v11 = p17.Occupant.Parent;
	end;
	if not v11 then
		p16:TeardownTransparency();
		return;
	end;
	p16:SetupTransparency(v11);
end;
local u1 = require(script.Parent:WaitForChild("CameraUtils"));
function v1.Update(p18)
	local v12 = tick();
	local l__CurrentCamera__13 = workspace.CurrentCamera;
	if l__CurrentCamera__13 then
		local v14 = 0;
		if p18.enabled then
			local l__magnitude__15 = (l__CurrentCamera__13.Focus.p - l__CurrentCamera__13.CoordinateFrame.p).magnitude;
			local v16 = l__magnitude__15 < 2 and 1 - (l__magnitude__15 - 0.5) / 1.5 or 0;
			if v16 < 0.5 then
				v16 = 0;
			end;
			if p18.lastTransparency then
				local v17 = v16 - p18.lastTransparency;
				if not false and v16 < 1 and p18.lastTransparency < 0.95 then
					local v18 = 2.8 * (v12 - p18.lastUpdate);
					v17 = u1.Clamp(-v18, v18, v17);
				end;
				v16 = p18.lastTransparency + v17;
			else
				p18.transparencyDirty = true;
			end;
			v14 = u1.Clamp(0, 1, u1.Round(v16, 2));
		end;
		if p18.transparencyDirty or p18.lastTransparency ~= v14 then
			for v19, v20 in pairs(p18.cachedParts) do
				v19.LocalTransparencyModifier = v14;
			end;
			p18.transparencyDirty = false;
			p18.lastTransparency = v14;
		end;
	end;
	p18.lastUpdate = v12;
end;
return v1;

