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

A bug in the script?

Asked by 8 years ago

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)

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
8 years ago

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.

Ad

Answer this question