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
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!