I am making a weapon shop, and I have a successful script so that if you have the money for something on the GUI you can buy it. What I can't figure out is how to subtract the cost of that weapon from the player's amount. here's the script:
local plr = game.Players.LocalPlayer
local replicatedstorage = game:GetService("ReplicatedStorage")
script.Parent.MouseButton1Click:connect(function()
if plr.leaderstats.Cash.Value >= 500 then
replicatedstorage.MachineGun:Clone().Parent = plr.Backpack
replicatedstorage.MachineGun:Clone().Parent = plr.StarterGear
if script.Parent.MouseButton1Click and plr.leaderstats.Cash.Value >= 500 then
game.plr.leaderstats.Cash.Value = game.plr.leaderstats.Cash.Value - 500
end
end
end)
Can you please tell me what's wrong, thank you very much!

2 comments
https://www.roblox.com/library/184275443/UltraWorks-Shop-Creator-Pro-tools
I think it was you who gave an anwer that was wrong, I was able to fix it and even though the script wasn't completely right I want to give you credit, repost it so that I can accept your answer!