My Cash is not decreasing when i buy an item
game.Players.PlayerAdded:Connect(function(player)
local Buy = player.PlayerGui:WaitForChild("Gui").Main.Info.Buy
local leaderstats = player:FindFirstChild("leaderstats")
local Cash = leaderstats:FindFirstChild("Cash")
local price = player.PlayerGui:WaitForChild("Gui").Main.Info.Price
local Gui = player.PlayerGui:WaitForChild("Gui").Main.Frame
local Purchased1 = Gui.Item1.Purchased
local Purchased2 = Gui.Item2.Purchased
local Purchased3 = Gui.Item3.Purchased
Buy.MouseButton1Click:connect(function()
print("Yeet")
if Cash.Value >= price.Value then
Cash.Value = Cash.Value - price.Value
if price.Value == 100 then
local oldGun = player.Backpack:FindFirstChildOfClass("Tool") or player.Character:FindFirstChildOfClass("Tool")
oldGun:Destroy()
game.ReplicatedStorage.Tools.Pistol:Clone().Parent = player.Backpack
Purchased1.Value = 1
end
if price.Value == 300 then
local oldGun = player.Backpack:FindFirstChildOfClass("Tool") or player.Character:FindFirstChildOfClass("Tool")
oldGun:Destroy()
game.ReplicatedStorage.Tools.Revolver:Clone().Parent = player.Backpack
Purchased2.Value = 1
end
if price.Value == 500 then
local oldGun = player.Backpack:FindFirstChildOfClass("Tool") or player.Character:FindFirstChildOfClass("Tool")
oldGun:Destroy()
game.ReplicatedStorage.Tools.Uzi:Clone().Parent = player.Backpack
Purchased3.Value = 1
end
end
end)
end)
