Problems with saving multiple values

I’m currently making a game where I have to save multiple values (like 5+ values) in the player’s leaderstats folder. I need help with a script that can save any amount of values with no problem.

Every time I leave and rejoin, none of the data is being saved of course. It just resets to the default values, which is 1. There are no errors being printed in console though.
I have tried many data store systems, but none of them seemed to work. I tried ProfileServices, Datastorev2, and normal trashy datastores. The problem with datastorev2 and profileservices is that I can’t update the values from a client.

This is my current datastore script that saves the values inside the script. (this is also broken)
local DataStoreService = game:GetService(“DataStoreService”)
local config = script:WaitForChild(“datastore_config”)
local myDataStore = DataStoreService:GetDataStore(“$Data$!”…config:FindFirstChild(“DataVersion”).Value)

local saving = config:FindFirstChild(“Saving”)
local autoSave = config:FindFirstChild(“AutoSave”)

local function create_table(plr)
local player_stats = {}

for _, folder in pairs(script:FindFirstChild("Plr"):GetChildren()) do
	if folder:IsA("Folder") then
		print(folder)
		for _, stat in pairs(plr:FindFirstChild(folder.Name):GetChildren()) do
			player_stats[stat.Name.." "..folder.Name] = stat.Value
		end
	end
end

return player_stats

end

local function saveData(plr)
local player_stats = create_table(plr)

local succes, err = pcall(function()
	local key = plr.UserId.."'s' Data"
	myDataStore:SetAsync(key, player_stats)
end)

if succes then
	print("Saved Data Correctly!")
else
	warn(err)
end

end

game.Players.PlayerAdded:Connect(function(plr)
local key = plr.UserId…“‘s’ Data”
local data = myDataStore:GetAsync(key)

print(data)

for _, folder in pairs(script:FindFirstChild("Plr"):GetChildren()) do

	if folder:IsA("Folder") then

		local fc = folder:Clone()
		fc.Parent = plr

		if saving.Value == true then
			for _, item in pairs(fc:GetChildren()) do			
				if data then
					item.Value = data[item.Name.." "..folder.Name]
					continue
				else
					warn("There is no data!")
					continue
				end
			end				
		end
	end
	
	while autoSave.Value > 0 do
		task.wait(autoSave.Value * 60)
		saveData(plr)
		print("Saved", data)
	end
	
end

end)

game.Players.PlayerRemoving:Connect(function(plr)
if saving.Value == true then
saveData(plr)
end
end)

I would loop through the descendants of the player’s leaderstat folder and use string.find(descendant.ClassName, “Value”) to determine if it is a value. If so, save as: data[descendant.Name] = descendant.Value. When repopulating the leaderstat folder, you can do this to make the right class of value:

for i,v in data do
    local val = Instance.new(typeof(v):gsub("^%l", string.upper) .. "Value")
    val.Name = i
    val.Value = v
    val.Parent = plr.leaderstats
end