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

How would i get the hair from a character?

Asked by 7 years ago
Edited 7 years ago

I am trying to make the whole players body go invisible but i don't know how to get the hair from a character

script.Parent.Touched:connect(function(h)
    if h.Parent:FindFirstChild("Humanoid") ~= nil then
        h.Parent:FindFirstChild("Left Arm").Transparency = 1
        h.Parent:FindFirstChild("Right Arm").Transparency = 1
        h.Parent:FindFirstChild("Left Leg").Transparency = 1
        h.Parent:FindFirstChild("Right Leg").Transparency = 1
        h.Parent:FindFirstChild("Torso").Transparency = 1
        h.Parent:FindFirstChild("Head").Transparency = 1
        h.Parent:FindFirstChild("Head").face.Transparency = 1
    end
end)

2 answers

Log in to vote
3
Answered by 7 years ago

Loop through the character and check if what's returned is a Hat.

We can use a Generic For Loop. We can then use the IsA function to check if what's returned IsA("Hat"). We will also use IsA to check if what's returned is a part.

script.Parent.Touched:connect(function(h)
    if h.Parent:FindFirstChild("Humanoid") ~= nil then
        h.Parent:FindFirstChild("Head").face.Transparency = 1
        for i,v in pairs(h.Parent:GetChildren()) do
            if v:IsA("Hat") then
                v:FindFirstChild("Handle").Transparency = 1
            elseif v:IsA("Part") then
                v.Transparency = 1
            end
        end
    end
end)

Hats have things called Handles, and if you set the Handle's transparency to 1 it makes it invisible. I tested this and it worked fine.

if I helped, please don't forget to accept my answer.
Ad
Log in to vote
-7
Answered by 7 years ago

remove :FindFirstChild

0
I don't want to remove i just want to make the Mesh Transparent.. TRILLFLOWS 135 — 7y

Answer this question