Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make player accessories invisible?

Asked by 4 years ago
Edited 4 years ago

I'm making a script where a player turns invisible when they activate a tool. I am able to make their BaseParts invisible (arms, legs torso.. etc), but their hats/glasses stay on.

for i, v in pairs (kinder) do
    local transparent = 1
        if v:IsA("BasePart") or v:IsA("Accessory")then
            v.Transparency = transparent
        end
end

kinder is a table of the character's children.

In this code, the error message is: Transparency is not a valid member of Accessory.

Is there any way to make the player fully invisible, including accessories?

0
if it worked, could you make my answer a solution raid6n 2196 — 4y

1 answer

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
for _, player in pairs(game.Players:GetPlayers()) do
    local character = player.Character

    for _, descendant in pairs(character:GetDescendants()) do
        if descendant:IsA("BasePart") then 
            descendant.Transparency = 1
        end
    end
end

0
Thank you, that worked perfectly. Is there a reason GetDescendants() works rather than GetChildren()? GreatValuePeas 7 — 4y
0
GetDescendents get all the children in childrens inside the parts and getchrilden dont i believe raid6n 2196 — 4y
0
if it worked, could you make this a solution raid6n 2196 — 4y
0
Because I have it in a local script inside of a tool, I found out that the invisibility is only local to the client; the server can still see a visible player. Do you know how to make the invisibility server-sided so that all players can see it? I tried moving it into a regular script and changing the Character to script.Parent.Parent, but the entire script is not firing, like Tool.Activated. GreatValuePeas 7 — 4y
0
Use remotevents. raid6n 2196 — 4y
Ad

Answer this question