Help with Data Stores

I want to create a easy to use maintainable data store system for my game.

The issue is that when I change one of the values in the ServerStorage.PlayersData it doesn’t save when I quit and re-join.

local function GiveData(player: Player)
	local profile = Manager.Profiles[player]
	if not profile then return end
	
	local Data = PlayersData:FindFirstChild(player.Name) or script.Data:Clone()
	Data.Name = player.Name
	Data.Parent = PlayersData
end

local function PlayerAdded(player: Player)
	local profile = ProfileStore:LoadProfileAsync("Player_"..player.UserId)
	if profile == nil then
		player:Kick("Data issue, please rejoin.")
		return
	end
	
	profile:AddUserId(player.UserId)
	profile:Reconcile()
	profile:ListenToRelease(function()
		Manager.Profiles[player] = nil
		player:Kick("Data issue, please rejoin.")
	end)
	
	if player:IsDescendantOf(Players) == true then
		Manager.Profiles[player] = profile
		GiveData(player)
	else
		profile:Release()
	end
end

This GiveData function above clones a Folder of all the data of the player into a PlayersData folder in serverstorage: here is how it looks.
image

local ProfileTemplate = {
	PrimaryWeapon = "Sword";
	PlayerBlessings = "";
	PlayerSigns = "";
	Kills = 0;
	Kunnan = Elements[math.random(1, #Elements)];
	Armor = "";
	Enchant = "";
	Level = 1;
	AnimationStyle = "TwoHand";
	Race = Races[math.random(1, #Races)];
}

This is the template of the player when they join.

Create a function for saving on player leaving.

	game.Players.PlayerRemoving:Connect(function(plr)
		local sus, err = pcall(function()
			dataKey:SetAsync(plr.CharacterAppearanceId, plr.leaderstats.Coins.Value)
		end) if not sus then warn(err) end	
	end)

One of my snippets. You’ll have to make it work for your case.

Do be sure to remember to change the value whilst play-testing in server mode (green border around viewport) instead of client mode (blue border around viewport)

You can change the mode by going to the TEST tab and clicking the Current: Client button

If you change a value on the client-side, the server won’t see it change, so the value will stay and save as it was set on the server-side