Help with ProfileService Management module

I have a ProfileService profiles manager for easy setting, getting values. They work ok for just variables but how can I use them for tables?
The module:

local knit = require(game.ReplicatedStorage.Packages.Knit)
module = knit.CreateService({
	Name = "PlayerDataManager",
	Client = {callbackRE = knit.CreateSignal()}
})
module.Profiles = {}
local settingCallbacks = {}

function module:CheckData(plr:Player)
	if module.Profiles[plr.UserId] then
		return true
	else
		return false
	end
end
function module:Get(plr:Player)
	local profile = module.Profiles[plr.UserId]
	if not profile then
		return
	end
	return profile.Data
end
function module:Set(plr,settingn,value)
	local setting = tostring(settingn).upper(settingn)
	local profile = module.Profiles[plr.UserId]
	if not profile then
		return
	end
	profile.Data[setting] = value
	module.Client.callbackRE:Fire(plr,setting,value)
	if settingCallbacks[setting] then
		for _, callback in ipairs(settingCallbacks[setting]) do
			callback(plr, setting)
		end
	end
end
function module:registerCallback(plr, setting, callback)
	local settingName = tostring(setting).upper(setting)
	print(plr,settingName,callback)
	if not settingCallbacks[settingName] then
		settingCallbacks[settingName] = {}
	end
	table.insert(settingCallbacks[settingName], callback)
end

for k,func in pairs(module) do
	module.Client[k] = k ~= "Set" and func
end
return module

And the template:

local module = {
	FOV = 100,
    MUSIC = true,
	LEVELS = 1, --how many levels has the player unlocked
	BEST_TIMES = {}; --lowest times the player has completed the level (for speedrunning)
}

return module

Note that any suggestion would help!

Hopefully, this is what you are looking for, let me know if it’s not.

function DataService:AdjustItem(player: Player, itemName: string, amount: number)
	local profile = Profiles[player]

	if profile then
		if profile.Items[itemName] then
			profile.Items[itemName].Amount += 1

            -- Removing the item from data table if player no longer owns any
			if profile.Items[itemName].Amount < 1 then
				profile.Items[itemName] = nil
			end
		else
			profile.Items[itemName] = { Amount = amount or 1 }
		end
	end
end

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