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

How to find and set player`s mask invisible?

I have a morth that gives me certain "skin", or character. The character has a head and a mask. I want the player to press M to remove the mask. Now, I dont want to destroy it, I want to make the player take it off and take it back on, so I am willing to make it transparent. But I dont know how, my script failed. I want the button M to take it off and if I press it again it will bring back the mask. How can I fix the script? Please help.

--// Variables:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()


--// Take Off The Mask:
mouse.KeyDown:connect(function(key)
    if key == "m" then
        script.Parent:FindFirstChild("Mask")
		if Mask.Transparency == 0 then
			Mask.Transparency = 1
		end
    end
end)


--// Take On The Mask:
mouse.KeyDown:connect(function(key)
    if key == "m" then
        script.Parent:FindFirstChild("Mask")
		if Mask.Transparency == 1 then
			Mask.Transparency = 0
		end
    end
end)

(The "Mask" is something thats inside the player`s character after I get the skin.)

2 comments

0

KeyDown is deprecated

0

Still not working

1 answer

Try this. Also you didn't set a variable for Mask, make sure you do that leading to the mask

--// Variables:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local input = game:GetService("UserInputService") -- The user input service
local maskOn = false -- Similar to debounce

--// Take OFF The Mask:
input.InputBegan:Connect(function(obj)
    if obj.KeyCode == Enum.KeyCode.M then
        if maskOn == true then
            Mask.Transparency = 1
            maskOn == false
        end
    end
end)


--// Put ON The Mask:
input.InputBegan:Connect(function(obj)
    if obj.KeyCode == Enum.KeyCode.M then
        if maskOn == false then
            Mask.Transparency = 0
            maskOn == true
        end
    end
end)

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