Hello, I have just edited a face giver script and converted it into a click giver, yet there is a problem for the fact that it dosen't do anything. What may be the cause? I have added a click detector.
local head = script.Parent function onClicked(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then 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)
The MouseClick
event is not at all like the Touched
event, where the built-in parameter is equal to a Part. That wouldn't even make sense for MouseClick
, since there is no actual physical object touching the brick.
For MouseClick
, the build in parameter is the Player that clicked. I actually like this parameter better than a Part, because we can access everything very easily. For example,
function onClicked(player) print(player.Name.." clicked!") end script.Parent.ClickDetector.MouseClick:connect(onClicked)
From here (using your player's Character
property) it's just a few simple edits to change the face texture. I'll leave you to try that out on your own, comment if you have questions.