Button does not detect the player's leaderstats

Hello developers, I recently made a script to spend money when you press a button, but I do not understand why it does not detect the leaderstats :frowning:

local MoneyNeeded = 2500
local dinero = player.leaderstats:WaitForChild(“Zeni”)

if dinero.Value >= MoneyNeeded then
	dinero.Value -= 2500
	print("You don't have enough money")

1 Like

MouseButton1Click does not return a parameter / the player. Use LocalPlayer if that is a LocalScript. If it is a serverscript, make a remote and a localscript and fire the remote to perform your check on the serverside.


1 Like

The script is in a server script, but why doesn’t it connect to the leaderstats?

MouseButton1click does not return a player so the player is nil. You need to make it into a localscript, make a remoteevent and do your actions serverside when the remote is fired.