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

How can I find a part inside my character and make it transparent?

I have a part inside my body thats called "Handle" and it has its own mesh. "Handle" is inside a "hat" (Like an accessory), I cant make "hat" transparent and I need to make "Handle" transparent. I need to find the "Handle" inside the character.

The "hat" is actually a mask I want to be able to remove and put back on whenever I want by pressing "M". However I cant get it right. I changed my script couple times, asked here the same question twice. I really want to make it work.

The script is a LocalScript inside the workspace. I go to a morth and get the "hat" inside me. Now when I press "M" nothing happens.


local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()
local maskOn = false

local mask = char:FindFirstChild("Handle") --Tried to find it this way (Handle is inside the "hat" which is inside my character)


uis.InputBegan:connect(function(key)
	if key.KeyCode == Enum.KeyCode.M then
		print("Check") -- Check to check if the script works, nothing happens.
		if maskOn == false then
			mask.Transparency = 1
			maskOn = true
		end
		if maskOn == true then
			mask.Transparency = 0
			maskOn = false
			print("Check") -- Same, nothing happens.
		end
	end
end)

If someone could help me solve this I will be really happy since I tried to fix it for the past 3 or 4 days. I am almost giving up. :/

1 answer

Just know this, local scripts won't work if it's a descendants of the workspace.

Try this and parent the local script anywhere it can run(ex. StarterPack):

local uis = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()
local maskOn = false

local mask = char:FindFirstChildOfClass('Accessory').Handle:FindFirstChildOfClass('SpecialMesh')

uis.InputBegan:connect(function(key)
    if key.KeyCode == Enum.KeyCode.M then
        print("Check") 
        if maskOn == false then
            mask.Transparency = 1
            maskOn = true
        end
        if maskOn == true then
            mask.Transparency = 0
            maskOn = false
            print("Check")
        end
    end
end)

4 comments

0

I tried it, same results. :

0

Did you re-parent the script? Any errors?

0

Yes I did, placed it in StarterPack. And no, stayed the same, no errors.

0

Edited code above, figured out that you needed to change the mesh's transparency

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