Okay, so I'm practicing with datastores (fun) and I've made this small script:
local dss = game:GetService("DataStoreService")
local ds = dss:GetDataStore("CashSaving1")
game.Players.PlayerAdded:Connect(function(plr)
wait(5)
local cash = plr.ContainFolder.Cash.Value
ds:GetAsync(plr.UserId, cash)
local key = plr.UserId
cash = ds:GetAsync(key)
cash.Changed:Connect(function()
ds:SetAsync(key, cash)
end)
end)
Yes, this is in a Server Script This is in ServerScriptService (I've tried placing this in other areas too, same error.) And I understand I didn't wrap it in a pcall function, not there yet, so with any code examples please don't include pcalls as it'll only make things more confusing. And no, I'm not asking for someone to make me a script. So my problem would be on line 10 .. It says the value doesn't exist.
"attempt to index local 'cash' (a nil value)"

5 comments
I get no errors, but it still isn't saving the value..
See my edited post :).
Now on line 10: attempt to index local 'cash' (a number value) .. I've tried adding .Value after cash on line 10, I've tried making the Async only save when leaving, and it isn't working.
Are you sure you're using the bottommost code? If so, Line 10 should be whitespace (and hence not error)
I ask since I don't see why such an error would exist