How can I save and load the accesorries via this leaderstats script?

I know how to save tools and leaderstats, but I wondered how to save accesorries?

local dataStore = game:GetService("DataStoreService")
local KillStore = dataStore:GetDataStore("KillStore")
local killEvent = game.ReplicatedStorage.KillEvent


local function DeleteBounty(plr)
	while wait(25) do
		if plr.Bounty.Value > 0 then
			plr.Bounty.Value -= 5
		end
	end
end

local function leaderstats(plr)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr

	local cash = Instance.new("NumberValue")
	cash.Name = "Cash"
	cash.Parent = leaderstats
	
	local bank = Instance.new("NumberValue")
	bank.Name = "Bank"
	bank.Parent = plr

	local Once = Instance.new("BoolValue")
	Once.Name = "Once"
	Once.Parent = plr
	
	local level = Instance.new("IntValue")
	level.Name = "Level"
	level.Parent = leaderstats
	
	local XP = Instance.new("IntValue")
	XP.Name = "XP"
	XP.Parent = plr
	
	local bounty = Instance.new("IntValue")
	bounty.Name = "Bounty"
	bounty.Parent = plr
	
	local needsLevelValue = Instance.new("IntValue")
	needsLevelValue.Name = "needsLevelValue"
	needsLevelValue.Parent = plr

	XP:GetPropertyChangedSignal("Value"):Connect(function()
		if XP.Value >= 250 * level.Value then
			needsLevelValue.Value += 250
			XP.Value = 0
			level.Value += 1
		end
	end)
	
	bounty:GetPropertyChangedSignal("Value"):Connect(function()
		if bounty.Value == 600 or bounty.Value == 1000 or bounty.Value == 2000 or bounty.Value == 5000 or bounty.Value == 10000 then
			game.ReplicatedStorage.BountyAlert:Fire(plr)
		end
	end)
	
	plr.CharacterAdded:connect(function(char)
		local humanoid
		repeat
			humanoid = char:FindFirstChild("Humanoid")
			wait()
		until humanoid
		humanoid.Died:connect(function() 
			local tag = humanoid:FindFirstChild("creator") 
			if tag then  
				local killer = tag.Value  
				if killer and killer ~= plr then   
					local killername = killer.Name
					killer.leaderstats.Cash.Value = killer.leaderstats.Cash.Value + 10
					killer.XP.Value = killer.XP.Value + 10
					killer.Bounty.Value = killer.Bounty.Value + 20
					killEvent:FireAllClients(plr,killername)
					if plr.Bounty.Value >= 550 then
						killer.Cash.Value  = killer.Cash.Value + plr.Bounty.Value / 2
					end
					
				end   
			end 
		end)
	end)
end

local function Save(plr)
	local data2
	local data3
	local data4
	local data5
	local data6
	local data7
	local data8
	local success,errormessage = pcall(function()
		data2 = KillStore:GetAsync(plr.UserId.."-needsLevelValue")
		data3 = KillStore:GetAsync(plr.UserId.."-cash")
		data4 = KillStore:GetAsync(plr.UserId.."-once")
		data5 = KillStore:GetAsync(plr.UserId.."-level")
		data6 = KillStore:GetAsync(plr.UserId.."-XP")
		data7 = KillStore:GetAsync(plr.UserId.."-bounty")
		data8 = KillStore:GetAsync(plr.UserId.."-bank")
	end)

	if success then
		plr:WaitForChild("needsLevelValue").Value = data2
		plr:WaitForChild("leaderstats").Cash.Value = data3
		plr:WaitForChild("Once").Value = data4
		plr:WaitForChild("leaderstats").Level.Value = data5
		plr:WaitForChild("XP").Value = data6
		plr:WaitForChild("Bounty").Value = data7
		plr:WaitForChild("Bank").Value = data8
	else
		print("There was an error while getting your data")
		warn(errormessage)
	end
end

local ToolFolder = game:GetService("ServerStorage"):FindFirstChild("Tools")
local DataStoreService = game:GetService("DataStoreService")
local SaveData = DataStoreService:GetDataStore("SaveData")




local function ToolData1(plr)
	local ToolData = SaveData:GetAsync(plr.UserId)

	local BackPack = plr:WaitForChild("Backpack")
	if ToolData ~= nil then
		for i,v in pairs(ToolData)do
			if ToolFolder:FindFirstChild(v) and BackPack:FindFirstChild(v) == nil then
				ToolFolder[v]:Clone().Parent = BackPack
			end
		end
	end

	plr.CharacterRemoving:Connect(function(Character)
		Character:WaitForChild("Humanoid"):UnequipTools()
	end)
end

local function ToolData2(plr)
	local ToolTable = {}

	for i,v in pairs(plr.Backpack:GetChildren()) do
		table.insert(ToolTable, v.Name)
	end
	if ToolTable ~= nil then
		SaveData:SetAsync(plr.UserId, ToolTable)
	end
end

local function Group(plr)
	if plr:WaitForChild("Once").Value == false then
		if plr:IsInGroup(5406474) then
			plr:WaitForChild("Once").Value = true
			plr.leaderstats.Cash.Value += 200
			plr:WaitForChild("XP").Value += 50
		end
	end
end

local function Save2(plr)
	local success,errormessage = pcall(function()
		KillStore:SetAsync(plr.UserId.."-needsLevelValue",plr.needsLevelValue.Value)
		KillStore:SetAsync(plr.UserId.."-cash",plr.leaderstats.Cash.Value)
		KillStore:SetAsync(plr.UserId.."-once",plr.Once.Value)
		KillStore:SetAsync(plr.UserId.."-level",plr.leaderstats.Level.Value)
		KillStore:SetAsync(plr.UserId.."-XP",plr.XP.Value)
		KillStore:SetAsync(plr.UserId.."-bounty", plr.Bounty.Value)
		KillStore:SetAsync(plr.UserId.."-bank", plr.Bank.Value)

	end)
	if success then

		print("player Data successfully saved!")
	else
		print("There was an error saving data!")
		warn(errormessage)
	end
end


game.Players.PlayerAdded:Connect(function(plr)
	leaderstats(plr)
	Save(plr)
	ToolData1(plr)
	Group(plr)
	DeleteBounty(plr)
end)

game.Players.PlayerRemoving:Connect(function(plr)
	Save2(plr)
	ToolData2(plr)
end)

game:BindToClose(function()
	for _, plr in game.Players:GetPlayers() do
		if game:GetService("RunService"):IsStudio() then
			Save2(plr)
			ToolData2(plr)
		end
	end
end)

Hello!

I can help you a little bit about that, to be able to save accessories in a database is depending on your case.

If you are using custom accessories, you can create a table with the names of the accessories that the player already has and save that same table in a database, so that when he comes back in, just download the table with the names of the accessories and say which ones he has.

Otherwise and it is a Roblox accessory. You can save the ID of the accessory in the same table and make a loadasset to load them in the world!

I mean custom accesories for example armor or a helmet or a gasmask that you can use in the game!

an example code could be this:

local accesories = {
 ["imnotservi"] = {
   "PantsBlue",
    "Eyes",
  },
} 

game.Players.PlayerAdded:Connect(function(plr)
   if accesories[plr.Name] then
     print("Loading accesories")
   end
end)

Could you create functions like AccesoryData1 or AccesoryData2 just like I did it with the ToolData?

I can do it for you but I can’t do it for free, you can do it for yourself, you can take the idea I gave you.