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

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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)
0
I tried it, same results. : HeyItzDanniee 252 — 5y
0
Did you re-parent the script? Any errors? Rare_tendo 3000 — 5y
0
Yes I did, placed it in StarterPack. And no, stayed the same, no errors. HeyItzDanniee 252 — 5y
0
Edited code above, figured out that you needed to change the mesh's transparency Rare_tendo 3000 — 5y
Ad

Answer this question