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

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

Asked by 7 years ago

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

Log in to vote
2
Answered by
Link150 1355 Badge of Merit Moderation Voter
7 years ago
Edited 7 years ago

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)
Ad

Answer this question