Work around for Player:LoadInstance

I have been trying to script one of those slots related to avatar customization , those that save your accessories i.e Humanoid:GetAccessories()
that you can load , after you rejoin a game.
After research I found out that most of the ways people could accomplish this was by utilizing Player:Loadstring and Player:LoadInstance and now-depreceated functions.

AccessoriesFolder is a saved folder parented to the Player, that’s taken care of,
but what I want to do is to save the accessories/outfit/costume of the player in-game whenever he clicks the save button

types , and parent everything in that folder through a loop to the player’s save-able folder mentioned before, AccessoriesFolder .
Upon rejoin I want the button that loads to parent everything from that folder, to the humanoid by
Humanoid:AddAccessory()

IF there is a work-around for this whole script, then please provide me some information .

Here is the script I used in the button, ServerScript

local Players = game:GetService("Players")
local player = Players.LocalPlayer

 local function clothify(player)

local tablet = require(game:GetService("InsertService"):LoadAsset(590549414).Table)

local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
 
local firstfoldchildren = player.AccessoriesFolder:GetChildren()
     local hash = #firstfoldchildren
    if not hash < 1 then     
local rg = player.AccessoriesFolder:Clone()
    local rc   tablet.convert(rg)
           for _,accessory in pairs (rc) do
	       humanoid:AddAccessory(accessory)
	             
end
     return
 end	      
	 	local accessories = {}
		for _, accessory in pairs(humanoid:GetAccessories()) do
		local newfold = tablet.convertr(accessories)
		  for _,child in pairs ( newfold:GetChildren()) do
			child.Parent = player.AccessoriesFolder
	
		-- save hats for later
	 
			table.insert(accessories, accessory:Clone())
		end
		  player.AccessoriesFolder:ClearAllChildren()
 local accessoriesUpdate = tablet.convert(accessories)
      accessoriesUpdate.Parent = player.AccessoriesFolder
		-- remove hats
		humanoid:RemoveAccessories()
 
		wait(5)
 
		-- make sure the player still exists, and has the same character
		if player and player.Character and player.Character == character then
			local humanoid = character:FindFirstChildOfClass("Humanoid")
			if humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
				-- give back the hats
				for _, accessory in pairs(accessories) do 
					humanoid:AddAccessory(accessory)
		
 

for _, player in pairs(Players:GetPlayers()) do 
	clothify(player)
        
     end
		end
			end
		   end
		 end 

   end

script.Parent.MouseButton1Click:Connect(clothify) 

Note : I modified Roblox’s script to make it work this way, but it doesn’t
I am 90 % sure there is a way more efficient method than this.

Data Persistence has been deprecated for years and is grossly unreliable. Use some kind of associative array. Keep a number id or the name of your accessory in a table.

Store all usable accessories in an accessible location like ServerStorage under an Accessories folder. When saving, collect the ids or names of the hats into a table and save that. When loading, iterate through the table of accessories. Find the related hat asset in your accessories folder, clone it and add it to the character.

3 Likes
local tablet = require(590549414)