function Give(player)
local PlayerPoints = player.leaderstats.BrickClicks
if PlayerPoints.Value < 19 then
PlayerPoints.Value = PlayerPoints.Value - script.Parent.Cost.Value else
print("You do not have enough brick clicks!")
end
end
script.Parent.MouseButton1Click:Connect(Give)
The error i get is
- Workspace.Part.SurfaceGui.TextButton.Script:2: attempt to index nil with 'leaderstats'

3 comments
Is this in a localscript or in a serverscript? MouseButton1Click won't run if it's a serverscript, and you can't change leaderstats with a localscript
im using a serverscript, so what should I connect it to>
Use a LocalScript with a RemoteEvent. Never use ServerScripts for gui based things.