I'm working a simulator game and this is a local script inside a textbutton. It's a upgrade gui for the simulator. The error is on line 4 (the error is: attempt to index nil with 'leaderstats'). Idk how to fix it so I'm asking the scriptinghelpers' community!
Thanks, notreallysupernova
local CarRespawn = game.ReplicatedStorage.Stats.CarRespawn
script.Parent.MouseButton1Click:connect(function(Player)
local stats = Player.leaderstats -- This is the error
local money = stats:WaitForChild("Money")
local price = 300
if money.Value >= price then
money.Value = money.Value - price
print("Purchased Upgrade")
CarRespawn.Value = CarRespawn.Value - 2
end
end)
