Profile Store reconcile

I’m running into an issue where I am adding data to my data template but for some reason, it is not getting reconciled for the player. Here is the related code

– DATA TEMPLATE

local template = {
	Kills = 0,
	Scrap = 500,
	Inventory = {
		Bikes = {
			"StarterBike",
		},
		Weapons = {}
	},
	OtherVars = {
		EquippedBike = "StarterBike"
	}
}

return template


-- Initialization

local profile = PlayerStore:StartSessionAsync(“Player_” … plr.UserId, {
Cancel = function()
return plr.Parent ~= Players
end,
})

if profile then		
	profile:AddUserId(plr.UserId)
	profile:Reconcile()
	
	profile.OnSessionEnd:Connect(function()
		DataMethods.Profiles[plr] = nil
		plr:Kick("Data error occurred. Please Rejoin")
	end)
	
	if plr.Parent == Players then
		DataMethods.Profiles[plr] = profile
		--print(profile.Data)
		Initialize(plr, profile)
	else
		profile:EndSession()
	end
else
	plr:Kick("Error")
end

Explan What The Code For. Do It Like: Load, Save, Cache Player Data Store OR Smth Else?

Ensure you’re passing your template table to ProfileStore:LoadProfileAsync or StartSessionAsync using profileStore:LoadProfileAsync(key, template) or similar with the template as the second argument.

Your code shows this:

local profile = PlayerStore:StartSessionAsync("Player_" .. plr.UserId, {
    Cancel = function()
        return plr.Parent ~= Players
    end,
})

But it does not include the template, so Reconcile() doesn’t know what to reconcile against.

This would be the correct structure:

local profile = PlayerStore:StartSessionAsync("Player_" .. plr.UserId, {
    Template = template, -- Required for proper reconciliation
    Cancel = function()
        return plr.Parent ~= Players
    end,
})

Also, if your template structure changed significantly (for example you renamed or removed keys), old profiles might not match up. Reconcile() will only add missing keys, it won’t delete or rename anything.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.