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

The face giver part doesn't work when you click on it, why?

So basically, there's a with a Decal in it, and once you click it, it supposes to change your face to it, but for some reason, it doesn't work, I also added the sound and the ClickDetector, here's the script:

local head = script.Parent
local sound = head:findFirstChild("Victory")

function onClicked(part)
	local h = part.Parent:findFirstChild("Humanoid")
	if h~=nil then
sound:play()
if part.Parent:findFirstChild("Head"):findFirstChild("face").Texture == nil then return end
part.Parent:findFirstChild("Head"):findFirstChild("face").Texture=script.Parent.Decal.Texture
	end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Once you click on it, it supposes to play a sound [Which is located on the part] and put you on the face.

NOTE: I put the Decal, clickDetector & the Sound on the Part.

1 answer

✓ Accepted answer

First off you should wait for the click detector. Most importantly MouseClick provides player who clicked, not the part. You must have accidentally treated this like an onTouched. Here:

local head = script.Parent
local sound = head:WaitForChild("Victory")

function onClicked(player)
	pcall(function()
		player.Character.Head.face.Texture = head.Decal.Texture
		sound:Play()
	end)
end

head:WaitForChild('ClickDetector').MouseClick:connect(onClicked)

2 comments

0

It's still doesn't work. :|

0

Forgot it's called "face" not "Face"

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