RunService=game:GetService("\082\117\110\083\101\114\118\105\099\101")FullyOpaqueDistance=32 LocalPlayer=game.Players.LocalPlayer GhostPlayersSetting=game.ReplicatedStorage.ClientConfig.GhostPlayers PlayerCharacters={}function RegisterPlayer(l)l.CharacterAdded:Connect(function(g)PlayerCharacters[l]=g if GhostPlayersSetting.Value==2 then SetTransparency(g,1)end end)l.CharacterRemoving:Connect(function(g)PlayerCharacters[l]=nil end)PlayerCharacters[l]=l.Character if l.Character~=nil and GhostPlayersSetting.Value==2 then SetTransparency(l.Character,1)end end function SetTransparency(l,g)assert(typeof(l)=="\073\110\115\116\097\110\099\101"and l:IsA("\077\111\100\101\108"),"\077\117\115\116 \112\114\111\118\105\100\101 \097 \118\097\108\105\100 \077\111\100\101\108\046")assert(typeof(g)=="\110\117\109\098\101\114","\077\117\115\116 \112\114\111\118\105\100\101 \097 \118\097\108\105\100 \110\117\109\098\101\114 \102\111\114 \116\114\097\110\115\112\097\114\101\110\099\121\046")local c=math.ceil(g*10)/10 if l~=PlayerCharacters[LocalPlayer]then for l,g in ipairs(l:GetDescendants())do if g:IsA("\066\097\115\101\080\097\114\116")then g.LocalTransparencyModifier=c end end end end function Update()if GhostPlayersSetting.Value==1 then local l=PlayerCharacters[LocalPlayer]and PlayerCharacters[LocalPlayer]:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")local g=l~=nil and l.Position or Vector3.new(0,0,0)for l,c in pairs(PlayerCharacters)do if l~=LocalPlayer then local l=c:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")local N=l~=nil and(l.Position-g).Magnitude or FullyOpaqueDistance local I=1-math.min(N/FullyOpaqueDistance,1)SetTransparency(c,I)end end end end for l,g in ipairs(game.Players:GetPlayers())do RegisterPlayer(g)end game.Players.PlayerAdded:Connect(RegisterPlayer)GhostPlayersSetting.Changed:Connect(function(l)if l==0 then for l,g in pairs(PlayerCharacters)do SetTransparency(g,0)end elseif l==2 then for l,g in pairs(PlayerCharacters)do SetTransparency(g,1)end end end)


RunService = game:GetService("RunService")

FullyOpaqueDistance = 32

LocalPlayer = game.Players.LocalPlayer
GhostPlayersSetting = game.ReplicatedStorage.ClientConfig.GhostPlayers

PlayerCharacters = {} -- List of character models indexed by player objects.

function RegisterPlayer(player)
	player.CharacterAdded:Connect(function(character)
		PlayerCharacters[player] = character
		if GhostPlayersSetting.Value == 2 then
			SetTransparency(character, 1)
		end
	end)
	player.CharacterRemoving:Connect(function(character)
		PlayerCharacters[player] = nil
	end)
	
	PlayerCharacters[player] = player.Character
	if player.Character ~= nil and GhostPlayersSetting.Value == 2 then
		SetTransparency(player.Character, 1)
	end
end
function SetTransparency(character, transparency)
	assert(typeof(character) == "Instance" and character:IsA("Model"), "Must provide a valid Model.")
	assert(typeof(transparency) == "number", "Must provide a valid number for transparency.")
	
	local roundedTransparency = math.ceil(transparency * 10) / 10
	
	if character ~= PlayerCharacters[LocalPlayer] then
		for i, item in ipairs(character:GetDescendants()) do
			if item:IsA("BasePart") then
				item.LocalTransparencyModifier = roundedTransparency
			end
		end
	end
end
function Update()
	if GhostPlayersSetting.Value == 1 then
		local playerTorso = PlayerCharacters[LocalPlayer] and PlayerCharacters[LocalPlayer]:FindFirstChild("HumanoidRootPart")
		local playerPosition = playerTorso ~= nil and playerTorso.Position or Vector3.new(0, 0, 0)
		
		for player, character in pairs(PlayerCharacters) do
			if player ~= LocalPlayer then
				local rootPart = character:FindFirstChild("HumanoidRootPart")
				local magnitude = rootPart ~= nil and (rootPart.Position - playerPosition).Magnitude or FullyOpaqueDistance
				local transparency = 1 - math.min(magnitude / FullyOpaqueDistance, 1)
				SetTransparency(character, transparency)
			end
		end
	end
end

for i, player in ipairs(game.Players:GetPlayers()) do
	RegisterPlayer(player)
end
game.Players.PlayerAdded:Connect(RegisterPlayer)

GhostPlayersSetting.Changed:Connect(function(value)
	if value == 0 then
		for player, character in pairs(PlayerCharacters) do
			SetTransparency(character, 0)
		end
	elseif value == 2 then
		for player, character in pairs(PlayerCharacters) do
			SetTransparency(character, 1)
		end
	end
end)