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

Scripted a simple disappear tool, yet entire character could not go transparent?

Asked by 6 years ago
Edited 6 years ago

This is a simple script which makes your character transparent, upon equipping.

tool = script.Parent.Parent
handle = tool.Handle


tool.Equipped:connect(function()
    for i,v in pairs(game.Players:GetPlayers()) do
        v.Character.Transparency = 0.5
    end
end)

For some reason, when I type " v.Character.Transparency = 0.5" my entire character is not disappearing unless it's a certain part of my character.

For example: v.Character.UpperTorso.Transparency = 0.5

.

1 answer

Log in to vote
2
Answered by
Newrown 307 Moderation Voter
6 years ago
Edited 6 years ago

This is simply because Transparency is not a property of a model, and a character is a model, Transparency is only a property of BaseParts.

So instead, you can iterate through all the parts in the character's model, and then set the transparency of each part.

So the code will look something like this:

tool = script.Parent.Parent
handle = tool.Handle


tool.Equipped:connect(function()
    for _,v in pairs(game.Players:GetPlayers()) do
        for _, part in pairs(v.Character:GetChildren()) do
            if part:IsA("BasePart") then -- make sure child is a basepart
                part.Transparency = 0.5
            end
        end
    end
end)

Note: This would change the transparency of all the players in the server, since you are iterating through every player, so whenever any of the players equip this tool, all the characters of the player in the server will go transparent, note sure if that is what you're trying to achieve

Hope it helped! If you have any questions let me know.

0
Thank you for the help. In your new script, "part" . Transparency seems to be underlined in red. What is the children of Character called? crystalclay 70 — 6y
2
Forgot the do in the second for loop, that's why part was underlined in red, sorry I didnt do it in studio, did it pretty quick, I edited the code though Newrown 307 — 6y
Ad

Answer this question