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

attempt to call field 'MouseButton1Click' (a userdata value) error?

So I have this script :

script.Parent.MouseButton1Click():connect(function(Onclicked)
	if game.Players.LocalPlayer.leaderstats.Level == 0 then
		
	end
end)

and it says this in the console Players.Player1.PlayerGui.Shop1Gui.Frame.ImageLabel.TextButton.LocalScript:1: attempt to call field 'MouseButton1Click' (a userdata value) Picture of the Player http://imgur.com/AO4LZMU

1 answer

✓ Accepted answer

MouseButton1Click is an Event, not a function. You do not call MouseButton1Click, you connect a function (called a callback) to it.

script.Parent.MouseButton1Click:connect(function()
	-- do something.
end)

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