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

An output error message on face remover script?

This script is to make the player's face disappear if they step on a part. This is the error I'm getting:

Head is not a valid member of Model.

and

face is not a valid member of UnionOperation.

(I'm not sure what these mean so I don't know how to fix it)

function onTouched(hit) 

hit.Parent.Head.face.Texture = ""

end 

script.Parent.Touched:connect(onTouched)

Or maybe there's just a better way of doing this?

2 comments

0

This worked fine for me.

0

It works fine, but I still recieve an error message.

2 answers

✓ Accepted answer

The issue is that your onTouched function will run regardless of what actually touched the part. So if something that doesn't have the exact structure of Parent > Head > face, your code's going to error.

Check that what you're removing is actually a player before you remove the face:

local function onTouched(hit)
	if (game.Players:GetPlayerFromCharacter(hit.Parent)) then -- Check that the hit's parent is a player
		if (hit.Parent:FindFirstChild("Head")) then -- Check that the player has a head
			if (hit.Parent.Head:FindFirstChild("face")) then -- Check that the head has a face
				hit.Parent.Head.face.Texture = "";
			end
		end
	end
end

script.Parent.Touched:connect(onTouched)

1 comment

0

Ah, now I understand. Thanks for helping me!

Maybe try

function OnTouched(hit)
hit.Parent.Head.Getchildren:Destroy
end

Sorry if it didn't work I'm new to scripting!

1 comment

0

I already recieved an answer, but thanks for trying to help!

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