Only coins value gets saved. I'm trying to make it so all my values are.
local DSService = game:GetService("DataStoreService"):GetDataStore("SaveStats")
game.Players.PlayerAdded:connect(function(player)
-- Define variables
local uniquekey = "id-"..player.userId
local leaderstats = Instance.new("IntValue", player)
local coinsvalue = Instance.new("IntValue", player)
local gemsvalue = Instance.new("IntValue", player)
local iqvalue = Instance.new("IntValue", player)
local tutorial = Instance.new("IntValue", player)
leaderstats.Name = "leaderstats"
coinsvalue.Name = "Coins"
gemsvalue.Name = "Gems"
iqvalue.Parent = leaderstats
iqvalue.Name = "IQ"
tutorial.Name = "tutorial"
-- GetAsync
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
coinsvalue.Value = GetSaved[1]
gemsvalue.Value = GetSaved[1]
iqvalue.Value = GetSaved[1]
tutorial.Value = GetSaved[1]
else
local NumbersForSaving = {coinsvalue.Value, gemsvalue.Value, iqvalue.Value, tutorial.Value}
DSService:SetAsync(uniquekey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(player)
local uniquekey = 'id-'..player.userId
local Cointable = {player.Coins.Value}
local Gemtable = {player.Gems.Value}
local IQtable = {player.leaderstats.IQ.Value}
local Tuttable = {player.tutorial.Value}
DSService:SetAsync(uniquekey, Cointable, Gemtable, IQtable, Tuttable)
end)

2 comments
Any errors in the output window?
"Async isn't working right", it's not that it's not working right. It's that you're not using it properly. SetAsync only requires a save key or name, and a value to be saved. https://scriptinghelpers.org/questions/27426/#30949