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

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

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

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.

2 comments

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?

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

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