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

Why its error:attempt an index nil with 'Transperency'?

Asked by 3 years ago
Edited 3 years ago

btw im new hehe help me please

function onTouch(part) 
local human = part.Parent:findFirstChild("Humanoid") 
if human ~= nil then 
part.Parent:findFirstChild("Torso").Transparency = 0
part.Parent:findFirstChild("Left Arm").Transparency = 0
part.Parent:findFirstChild("Right Arm").Transparency = 0
part.Parent:findFirstChild("Left Leg").Transparency = 0
part.Parent:findFirstChild("Right Leg").Transparency = 0
part.Parent:findFirstChild("Head").Transparency = 0
end 
end 
script.Parent.Touched:connect(onTouch) 



2
If you are using r15 characters then this will likely not work. greatneil80 2647 — 3y
0
Please directly index the bodyparts since you are not detecting if it is there, also most probability the character did not load or the character is R15, use player.CharacterAppearanceLoaded Xapelize 2658 — 3y
0
Consider replacing all the findFirstChild to WaitForChild Xapelize 2658 — 3y

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
3 years ago
local CharacterName = "Xapelize" -- Set this to the player name you want to hide

game:GetService("Players").PlayerAdded:Connect(function(player)
    player.CharacterAppearanceLoaded:Connect(function(character)
        wait(0.5) -- Some debug
        if character.Name == CharacterName then -- Detect if it's the PlayerName
            for _, DetectingPart in pairs(game.Workspace:WaitForChild("Xapelize"):GetChildren()) do -- Get everything on your character
                if DetectingPart:IsA("Accessory") then -- If it's accessory
                    DetectingPart.Parent = game:GetService("ServerStorage") -- Set the parent to ServerStorage (stores accessory inside it so you can get it back anytime)
                    print(DetectingPart.Name .." is an accessory")
                elseif DetectingPart:IsA("MeshPart") or DetectingPart:IsA("Part") then -- The reason why is there part is because Head is a Part
                    DetectingPart.Transparency = 1 -- Hide it
                    print(DetectingPart.Name .." is a mesh part")
                else -- Neither Accessory nor MeshPart nor Part
                    print(DetectingPart.Name .." is neither accessory nor mesh part, it's a ".. DetectingPart.ClassName) -- Print some stuff
                end

                if DetectingPart:IsA("Part") and DetectingPart.Name == "Head" then -- If the DetectingPart is head
                    for _, DetectingChildrenHead in pairs(DetectingPart:GetChildren()) do -- Get the children of Head
                        if DetectingChildrenHead:IsA("Decal") then -- If it's a decal (face)
                            DetectingChildrenHead.Transparency = 1 -- Hide face
                        end
                    end
                end
            end

            print("Character".. CharacterName .." is invisible")
        else
            print(player.Name .." is not ".. CharacterName)
        end
    end)
end)
0
If you are confused then I will explain, but the script comments might help you Xapelize 2658 — 3y
0
Also this is a script, put it in ServerScriptService Xapelize 2658 — 3y
0
by the way this is a invisible character script i misread the question Xapelize 2658 — 3y
0
In your question comments section I fixed your problem, try it, also this is just backup whenever you need it then get it here Xapelize 2658 — 3y
View all comments (3 more)
0
Is line 7 :WaitForChild("Xapelize") supposed to be :WaitForChild(CharacterName) ? loowa_yawn 383 — 2y
0
yeah Xapelize 2658 — 2y
0
Ignore this post because it's bad Xapelize 2658 — 2y
Ad

Answer this question