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

How do I make the player invisible?

Asked by 7 years ago

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?

0
I don't need fancy fades or anything complicated like that. I am just stuck and confused... ToxicCan175 4 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago
-- 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

0
you shouldnt use .ClassName == "Part", use :IsA("BasePart"), :IsA("Accoutrement"), and :IsA("Tool") Kampfkarren 215 — 7y
1
There's nothing wrong with comparing the ClassName property. IsA just gives you the option for checking base classes, which he's not doing here. I'd recommend using IsA for everything, but it's not required, and it doesn't deprecate ClassName. ScriptGuider 5640 — 7y
0
Oh. I was unnaware that :IsA() was a better way to check ClassNames. DragonOfWar900 397 — 7y
Ad

Answer this question