Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited by User#24403 5 years ago

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.

```lua

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. ^^

0
Replace :findFirstChild to :FindFirstChild MiniPolak 7 — 5y
0
I think it should help MiniPolak 7 — 5y
0
No wait i know in head:findFirstChild("Victory") is wrong symbol MiniPolak 7 — 5y
0
There i put it in code block User#24403 69 — 5y
0
Use :Clone() option MiniPolak 7 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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

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 HomieFirePGN 137 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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.

Answer this question