I am working on a game and I have a script in StarterCharacterScripts. I already have the whole script finished except for this part; I want it to make players invisible, including their tool. What code would I use?
-- Loops through all of the character's children for _, item in pairs (character:GetChildren()) do -- If the item is a part (This means that this is probably a body part), set the transparency to 1 (100% Transparent) if item.ClassName == "Part" then item.Transparency = 1 -- If the item is an accesssory or a tool, loop through all of the accessory's children elseif item.ClassName == "Accessory" or item.ClassName == "Tool" then for _, accessoryPart in pairs (item:GetChildren()) do --If it finds a part, set it to transparent if accessoryPart.ClassName == "Part" then accessoryPart.Transparency = 1 end end end end
Basically, this will search through the character for any part, and set it transparent. Though if the character has accessories, then the script will look through the accessory and set the parts to transparent. Though, keep in mind that if the player pulls out an other tool, the tool might not be transparent, so you have to make something that will check for when the player equips a tool, set the parts in it to transparent