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

How do I make my face decal change?

I was making an infection game (and infection pack) and I try to use this script:

local part = script.Parent
local faceLink = "rbxasset://20418518"

local function onPartTouched(otherPart)
	-- Get the other part's parent
	local partParent = otherPart.Parent
	-- Look for a humanoid in the parent
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		-- Do something to the humanoid, like set its health to 0
		partParent.Head.Face[0]:Destroy()
		partParent.Head.Face.Texture = faceLink
	end
end

part.Touched:Connect(onPartTouched)

and it does not work! How do I make the face change?

2 comments

0

Hey! Thanks for the reply. I have noticed that if the part touches with other part, it will send an error that Head is not a valid member of Part. I have fixed the script for you. Also sorry for posting this comment here, the purpose is to let you get the notification.

0

Hmm, Still won't work, I recorded footage at (shortened link) https://rb.gy/rloplj

1 answer

You destroyed the face before you change the face texture. Your script should be like this:

local part = script.Parent
local faceLink = "rbxasset://20418518"

local function onPartTouched(otherPart)
    -- Detect if there is humanoid, I did a mistake in here, the reason of detecting humanoid is because detect if it's a valid character
    if otherPart.Parent:FindFirstChild("Humanoid") then
        -- Get the other part's parent
        local partParent = otherPart.Parent
        -- Set the face to faceLink
        partParent.Head.Face.Texture = faceLink
    end
end

part.Touched:Connect(onPartTouched)

1 comment

0

@Xapelize Your script doesn't work for some reason...

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