Hi,
I've been messing around with DataStores, and I thought I got it to work. Basically, there are four values, the first of which saves, but the rest don't.
Here's the code that loads/saves Stores:
game.Players.PlayerAdded:connect(function(plr)
local cash = Instance.new("IntValue",plr)
cash.Name = "cash"
local heat = Instance.new("IntValue",plr)
heat.Name = "heat"
local health = Instance.new("IntValue",plr)
health.Name = "health"
local fatigue = Instance.new("IntValue",plr)
fatigue.Name = "fatigue"
local key = "user_"..plr.userId
cash.Value = cashStore:GetAsync(key)
heat.Value = heatStore:GetAsync(key)
health.Value = healthStore:GetAsync(key)
fatigue.Value = fatigueStore:GetAsync(key)
end)
game.Players.PlayerRemoving:connect(function(plr)
cashStore:UpdateAsync("user_"..plr.userId,function(oldValue)
return (plr.cash.Value or oldValue)
end)
heatStore:UpdateAsync("user_"..plr.userId,function(oldValue)
return (plr.heat.Value or oldValue)
end)
healthStore:UpdateAsync("user_"..plr.userId,function(oldValue)
return (plr.health.Value or oldValue)
end)
fatigueStore:UpdateAsync("user_"..plr.userId,function(oldValue)
return (plr.fatigue.Value or oldValue)
end)
end)
Honestly, I think I'm just going to save the four values as a table into DataStore, but for future reference, what's the problem here?

2 comments
Try using :SetAsync rather than :UpdateAsync, see if that does anything
I need to keep the old value in mind, and the wiki says using :Set and :Get in conjunction instead of :Update is dangerous.