Hi all.
A friend helped me design a script that makes a players character invisible to everyone, but I can’t get it to work. The character should be invisible, including decals and accessories.
while wait() do
for i,v in pairs(game.Players:GetPlayers()) do
for i,v in pairs(workspace:FindFirstChild(v.Name):GetDescendants()) do
if v:IsA("BasePart") or v:IsA("Decal") then
if v.Name == "HumanoidRootPart" then
else
v.Transparency = 0
end
end
end
end
for i,v in pairs(workspace:FindFirstChild(v.Name):GetDescendants()) do
if v:IsA("BasePart") or v:IsA("Decal") then
v.Transparency = 1
end
end
end
function playerAddedEvent(player)
--Must be done on spawn so that the body is invisible first
player.CharacterAdded:Connect(function(character)
task.wait()
for _, part in character:GetDescendants() do
if not part:IsA("BasePart") and not part:IsA("Decal") then continue end
part.Transparency = 1
end
end)
--Then must be done again when appearance such as accessory loads in
player.CharacterAppearanceLoaded:Connect(function(character)
for _, part in character:GetDescendants() do
if not part:IsA("BasePart") and not part:IsA("Decal") then continue end
part.Transparency = 1
end
end)
end
game.Players.PlayerAdded:Connect(function(player)
playerAddedEvent(player)
end)
for _, player in game.Players:GetPlayers() do
playerAddedEvent(player)
end
--Then must be done again when appearance such as accessory loads in
player.CharacterAppearanceLoaded:Connect(function(character)```
The 'player' is underlined in red, does this mean I have to declare what player is?
function playerAddedEvent(player)
--Must be done on spawn so that the body is invisible first
player.CharacterAdded:Connect(function(character)
end)
task.wait()
for _, part in character:GetDescendants() do
if not part:IsA("BasePart") and not part:IsA("Decal") then continue end
part.Transparency = 1
end
end
--Then must be done again when appearance such as accessory loads in
player.CharacterAppearanceLoaded:Connect(function(character)
end)
for _, part in character:GetDescendants() do
if not part:IsA("BasePart") and not part:IsA("Decal") then continue end
part.Transparency = 1
end
end
end
game.Players.PlayerAdded:Connect(function(player)
playerAddedEvent(player)
end)
for _, player in game.Players:GetPlayers() do
playerAddedEvent(player)
end
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local plrcharacter = game.Workspace:WaitForChild(character.Name) or player.Character or player.CharacterAdded:Wait()
local Head = plrcharacter:WaitForChild("Head")
for i,v in pairs(plrcharacter:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Part") then
if v.Name ~= "HumanoidRootPart" then
v.Transparency = 1
end
for i,v in pairs(Head:GetDescendants()) do
if v:isA("Decal") then
v:Destroy()
end
print(player.Name.."'s character has turned invisible")
end
end
end
end)
end)