Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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) 



3 comments

2

If you are using r15 characters then this will likely not work.

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

0

Consider replacing all the findFirstChild to WaitForChild

1 answer

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)

7 comments

0

If you are confused then I will explain, but the script comments might help you

0

Also this is a script, put it in ServerScriptService

0

by the way this is a invisible character script i misread the question

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

0

Is line 7 :WaitForChild("Xapelize") supposed to be :WaitForChild(CharacterName) ?

0

yeah

0

Ignore this post because it's bad

This discussion is preserved as it was. New answers, comments, and votes are closed.