Get a Leaderstat from a Gui

I tried searching for some help on this on the forum but couldn’t find anything. What I’m trying to do is check the players leaderstats whenever they click a gui for example:
Screen Shot 2020-09-16 at 4.36.53 PM
I’m trying to do this so I can cross out all the ones that the player can’t buy. Here is the script:

local Player = game.Players.LocalPlayer

local PlayerGui = Player:WaitForChild("PlayerGui")

local openbutton = PlayerGui.ScreenGui.SHOPBUTTON.TextButton

local Gui = PlayerGui.ScreenGui.ShopGUI
local event = game.ReplicatedStorage.remoteevent

openbutton.MouseButton1Click:Connect(function(p)
	
	if Gui.Visible == false then
		Gui.Visible = true
		
		end
	if Gui.Visible == true then
		
		---Check their leaderstats
			
		end
	
	
	
end)

If you can help me out, please do. Thanks.

Checking leaderstats is super simple! All you do is add this:

if player:WaitForChild("leaderstats"):FindFirstChild("Money").Value < 1000 then -- however much you want it to cost and the name of your leaderstat
	GUI.Visible = false
end

If you need me to explain more, let me know.

1 Like