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

How would I remove a player's face?

I was wondering how I would script a button that removes a player's face when it's touched. I know how to do the onTouched part, but whenever I try to go into the player with the get humanoid way, it says "Head is not a valid member of Player". Help? This is for a morph btw

1 answer

✓ Accepted answer

In order to remove the face of a player's character, we'll have check if the part touching the button is a child of a player. We should also check to see if the part has a humanoid (which was good for you to use in the first place, however you likely messed up on the conditional statement).

EDIT: I went ahead and re-coded this script to be more efficient when locating a face, as my last code error'ed after the face was removed from the player's character.

local deb = true -- set up a debounce 
local part = script.Parent -- set a variable for our part being touched

part.Touched:connect(function(hit)
    if hit.Parent:findFirstChild("Humanoid") ~= nil and deb then -- if humanoid exists and deb == true, proceed on-wards
	
    deb = false

    local head = hit.Parent:FindFirstChild("Head") -- finds the head
	
	for i,v in pairs (head:GetChildren()) do -- searches children of 'Head'
		if v:IsA("Decal") then
			v:remove() -- removes 'face' if a decal is detected
		else
			print("Not a valid decal instance")
		end
	end

        else
            print("Part is not a child of a character") 
    end

    wait(1)
    deb = true
end)

Questions / comments? Feel free to message me and I'll answer them as soon as possible. If you are satisfied with the answer I provided, please upvote me. Thanks!

4 comments

0

I see two errors in this script. On line 5 you need to get the parent of the part first before finding the head. You would also need a capital F in FindFirstChild. But overall it's an okay answer :P

0

Oh right, forgot to get the parent of 'hit'. Also, it doesn't really matter if you capitalize the :findFirstChild() function as it will work regardless. Thanks for the notifications though!

0

I saw one error with the script :P

0

Refurbished code, there are no more errors.

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