How to add a decal face to your avatar when you sit down

Hi there-
I am currently trying to create something where when you sit down on a seat your avatar is equipped with a decal for your face. (For a face mask) - I’ve tried multiple times to try find ways to do this however can’t and as I do not script I’m pretty much clueless.

If you know how I could achieve this please let me know below as it would hugely help me, thank you!

1 Like

You can either use GetPropertyChangedSignal on a seat’s Occupant if you need this to happen for a small number of specific seats or Seated if you have a large number of seats you need to do this from. In the latter case, the SeatPart occupied by the character will be passed as the second argument if the player sat down in one – you can then check if the seat matches a criteria (e.g. has a “GiveMask” attribute).

All characters have a default decal in their Head called “face” (case sensitive) which you can change the Texture of to your face mask decal. When you use either of the above methods to check for a Humanoid that sat, you will have access to the Humanoid. The character is the parent of that Humanoid. The head lives as a direct child of the character and likewise the face of the head.

Ideally you will need to preserve the old face if you want to revert it when they are unseated as well, so you can store the old face as an attribute as well.

Here’s an example of what you may look at in the end. It is not full code so there are things missing, but I do hope it provides guidance and helps see what my suggestion’d look like in practice. I’ll be going with the Humanoid.Seated method for this example since it’s what I’d do personally.

local FACE_MASK_TEX = "rbxassetid://362505168"

local function onSeated(didSit, seatPart)
	-- Don't do anything if this isn't a face changer seat
	if seatPart and not seatPart:GetAttribute("ChangeFace") then return end

	local face = Character:FindFirstChild("face", true)
	-- Don't do anything if the character unexpectedly does not have a face
	if not face then return end

	-- Store the face for the first time
	if not face:GetAttribute("OriginalTexture") then
		face:SetAttribute("OriginalTexture", face.Texture)
	end

	if didSit then -- Did they sit down?
		face.Texture = FACE_MASK_TEX
	else -- They didn't sit down
		face.Texture = face:GetAttribute("OriginalTexture")
	end
end

Humanoid.Seated:Connect(onSeated)

Video demonstration below. Notice how when I sit, my character’s face gets redder eyes (used Red Glowing Eyes for this since it was the quickest decal I had on hand, but it contrasts badly with Evil Skeptic… you should still be able to see the change though).

2 Likes

This was so helpful and I appreciate the detail you’ve put into this to explain and show me how to create what I wanted, the only problem I am having since I have no experience in the scripting field is where to put the script you’ve provided me in. Is it a LocalScript that I add onto the seat part to make it function? Please let me know as the video you provided is exactly the thing I’m looking for. Thanks.

image

I used a Script in StarterCharacterScripts for this. If you use a LocalScript the face change would only get seen by the current player. Additionally, I picked StarterCharacterScripts so that the script will come along with every new character and you don’t have to worry about handling new or respawning character cases.

StarterCharacterScripts is under StarterPlayer.

2 Likes

Thanks - Do you have Discord by any chance as I have a few questions to ask you. I appreciate however all the help you’ve given me for this.

If so please add me.
olly#9999

Just ask him here, the devforum is a public resource, so it doesn’t make sense to privately ask questions that future readers may have.

2 Likes

Why recursively iterate over every child of the character when the face decal is going to be inside the character’s head joint?

local head = character:FindFirstChild("Head")
if not head then return end
local face = head:FindFirstChild("face")
if not face then return end

Just I receive notifications faster through Discord and find it easier to use. I have no problem using the forums however it’s just for faster replies.

FWIW: got an extra help question via PMs regarding it not working. Not sure if anyone else might encounter that while using this (I did test) but in the instance that does happen, I’ll share my repro file which does have the full code in it, mainly just assignments for the character and humanoid.

I hope the main takeaway for any learning programmers is the explanation on how to do this and not the exact code I’m using, semantics and all. That’s just sample code and the way I do it personally.

SeatRepro.rbxl (35.0 KB)

1 Like