Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone help me?. My Shop script is not working. My cash wont decrease when i buy an item [closed]

Asked by 4 years ago

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)

Closed as Too Broad by User#24403

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?