Basically, I've made it so when a GUI button is pressed, it gives the player a tool. Now I am trying to make it so you need a certain amount of cash to buy it. I have already made the leaderstat for the cash, so now I just need to make it so you can buy it and it takes away the amount of money. I would like it so it costs 100 cash. Here is my script:
local Button = script.Parent
local Gun = game.ReplicatedStorage.Weapons.Pistol
local Players = game:GetService("Players")
local player = Players.LocalPlayer
Button.MouseButton1Click:Connect(function(player)
local leaderstats = player:FindFirstChild("leaderstats")
local Cash = leaderstats and leaderstats:FindFirstChild("Cash")
if Cash > 99 then
Cash =- 100
Gun:Clone()
Gun.Parent = game.Players.LocalPlayer.Backpack
end
end)
All answers appreciated! Thanks!!
