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

Why can't I save a value to the DataStore when the value changes?

Asked by 4 years ago
Edited 4 years ago

I'm making a game that has a leaderboard system. This is inserted inside the leaderboard part that goes into the player.

The script is trying to check if the cash is being changed. Even when it does change, nothing happens. What am I doing wrong?

The code:

local DSS = game:GetService("DataStoreService")
local Money = DSS:GetDataStore("ThisGameCashBlaBsshdaklsdjsalkd")
local CashValue = script.Parent.Cheeses
game.Players.PlayerAdded:connect(function(p)
    local pCash = Money:GetAsync(p.UserId) or 0
    CashValue.Value = pCash
    CashValue.Changed:Connect(function(v)
        Money:SetAsync(p.UserId,v)
        print("saving cash data")
    end)
end)

0
CashValue:GetPropertyChangedSignal("Value"):Connect(function(), .Changed is deprecated. Ziffixture 6913 — 4y

Answer this question