I've been trying to make a GUI shop with my existing leaderstats and it isn't working heres the code. It is inside of a Gui and the script is a script and to test i click run and it prints out that message.
``local player = game.Players.LocalPlayer local money = player.leaderstats.Coins.Value
local rs = game:GetService("ReplicatedStorage") local carridge = rs:WaitForChild("Stagecoach")
if script.Parent.MouseButton1Click then
if money < 400 then
print("false")
script.Parent.Parent:Destroy()
end
if money >= 400 then
local clone = carridge:Clone()
clone.Parent = game.Workspace
clone.Position = game.Workspace.wagonspawn
end
end``
and i get this error message: 16:14:53.609 - Players.EyeDontLie.PlayerGui.CarridgeshopGui.Frame.1Button.Script:2: attempt to index nil with 'leaderstats'
I don't know whats wrong and or what to do, Keep in mind im fairly new to scripting.

3 comments
It is still not working and i'm getting the same error message and now the gui is not showing up, so do you have any other ideas or should I try to make a shop another way?
create a liderstats folder
leader