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

A bug in the script?

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

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.

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