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

Cash given back after purchase?

Asked by 4 years ago

I am working on a car spawner script that works well except for 1 thing..... The money is given back after the purchase any clue? here is the local script:

script.Parent.MouseButton1Click:Connect(function()

    if script.Parent.Parent.Purchased.Value == true then

            game.ReplicatedStorage.SpawnCar:FireServer(script.Parent.Parent.Name)
        else

        local PriceOfItem = game.ReplicatedStorage:WaitForChild("CheckPrice"):InvokeServer(script.Parent.Parent.Name)

        if game.Players.LocalPlayer.leaderstats.Cash.Value >= PriceOfItem and script.Parent.Parent.Purchased.Value == false then

            game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value - PriceOfItem
            script.Parent.Parent.Purchased.Value = true

    end
    end
end)

0
You are changing the money value in the client which will not be reflected to the server. I recommend you using an remote event to change the money for the player. XviperIink 428 — 4y

Answer this question