local data = game:GetService("DataStoreService"):GetDataStore("Saves") local data = game:GetService("DataStoreService"):GetDataStore("Gold") local settings={ groupid = 2903819 } game:GetService("Players").PlayerAdded:connect(function(player) local key = "user_"..player.UserId local leaderstats = Instance.new("Folder", player) leaderstats.Name = "leaderstats" local rank = Instance.new("StringValue", leaderstats) rank.Name = "Rank" rank.Value = player:GetRoleInGroup(settings["groupid"]) local GetPlayerSave = data:GetAsync("user_"..player.UserId) local points = Instance.new("NumberValue", leaderstats) points.Name = "Saves" if GetPlayerSave then points.Value = GetPlayerSave[1] or 0 else points.Value = 0 end local points = Instance.new("NumberValue", leaderstats) points.Name = "Gold" if GetPlayerSave then points.Value = GetPlayerSave[1] or 0 else points.Value = 0 end end) game:GetService("Players").PlayerRemoving:connect(function(player) local leaderstats = player:WaitForChild("leaderstats") local ToSave = {leaderstats.Saves.Value} local ToSave = {leaderstats.Gold.Value} data:SetAsync("user_"..player.UserId, ToSave) end)
I want two things to save, Saves and Gold, both don't seem to work now despite it was working before when it had one value.
I believe solving this would need folders to save each player's storage, otherwise returning the 2 values as nil.
P.S. Why do you need a 'Saves' value?
EDIT: Requested a fix by the owner
local data = game:GetService("DataStoreService"):GetDataStore("Saves") local data = game:GetService("DataStoreService"):GetDataStore("Gold") local settings={ groupid = 2903819 } game:GetService("Players").PlayerAdded:connect(function(player) local key = "user_"..player.UserId local leaderstats = Instance.new("Folder", player) leaderstats.Name = "leaderstats" local rank = Instance.new("StringValue", leaderstats) rank.Name = "Rank" rank.Value = player:GetRoleInGroup(settings["groupid"]) local GetPlayerSave = data:GetAsync("user_"..player.UserId) local gSaves = Instance.new("NumberValue", leaderstats) -- Replacing this part of the script. gSaves.Name = "Saves" if GetPlayerSave then gSaves.Value = GetPlayerSave[1] or 0 else gSaves.Value = 0 end local points = Instance.new("NumberValue", leaderstats) points.Name = "Gold" if GetPlayerSave then points.Value = GetPlayerSave[1] or 0 else points.Value = 0 end end) game:GetService("Players").PlayerRemoving:connect(function(player) local leaderstats = player:WaitForChild("leaderstats") local ToSave = {leaderstats.Saves.Value} local ToSave = {leaderstats.Gold.Value} data:SetAsync("user_"..player.UserId, ToSave) end)