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

How can I edit this Face Changer script to add a decal, not replace it?

I'm quite new to scripting... and I'm still learning the ropes. However this is one thing for the life of me I can't do.. that seems SO SIMPLE.

I'm trying to add an add on for the players face when they touch a part, but all I have is a normal face changer. I don't want it to replace the face, only add on top of it.


  

local head = script.Parent

local sound = head:findFirstChild("Victory")

  

function onTouched(part)

local h = part.Parent:findFirstChild("Humanoid")

if h~=nil then

sound:play()

if part.Parent:findFirstChild("Head"):findFirstChild("face") then return end

part.Parent:findFirstChild("Head"):findFirstChild("face").Texture=script.Parent.Decal.Texture

end

end

  

script.Parent.Touched:connect(onTouched)

If you could help that'd be awesome. ^^

5 comments

0

Replace :findFirstChild to :FindFirstChild

0

I think it should help

0

No wait i know in head:findFirstChild("Victory") is wrong symbol

0

There i put it in code block

0

Use :Clone() option

2 answers

local head = script.Parent

local sound = head:findFirstChild("Victory")

function onTouched(part)

local h = part.Parent:findFirstChild("Humanoid")

if h~=nil then

sound:play()

if part.Parent.Head.face then return end

local clone = part.Parent.Head.face:Clone() --Cloning the object clone.Parent = part.Parent.Head --Making sure that the parent is "Head" clone.Texture = script.Parent.Decal.Texture --Setting the texture end

end

script.Parent.Touched:connect(onTouched)

Note:

  1. Try not to use the FindFirstChild() function too much, your script might be harder to understand.
  2. The Clone() function will clone an object

1 comment

0

I was on my phone so don't make fun of me that I don't know how to use the code block thingy

The :Clone() function should do the trick. To use it, just do FaceDecal:Clone() and be sure to set it's parent to the player's head, as by default, a clone's parent is nil.

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