I’m currently trying to serialize accessories for saving them for an outfit game and I’m trying to get the ids of layeredclothing applied to the character. One way I could do it is with HumanoidDescription.AccessoryBlob but it’s not accessible by lua code. What are some workarounds to this? Maybe a way to extract an ID from an accessory instance?
You can do something like this.
local function GetAccessoryID(Accessory)
return Accessory.Handle.MeshId
end
MeshId would return the accessory’s mesh, not the accessory’s ID itself.
If you’re attempting to serialize accessories, particularly layered clothing, applied to a character in Roblox, and you’re finding that HumanoidDescription.AccessoryBlob isn’t directly accessible from Lua, you’ll need to explore alternative methods to achieve your objective. One potential workaround involves inspecting accessory instances attached to the character. By iterating through these instances, you can extract relevant information such as the AssetId or AccessoryType to gather details about each accessory. For layered clothing components, you may need to delve deeper into the accessory’s properties to identify the layered clothing elements present.
Another approach is to leverage the MarketplaceService, which allows you to retrieve information about accessories using their Asset IDs. This service enables you to fetch details like the name, description, and asset type of each accessory. However, note that this method may not directly provide information about layered clothing unless the accessory explicitly indicates its involvement in layered clothing.
Alternatively, you can implement a custom data storage system to track the accessories equipped by each player’s character. Whenever a player equips or modifies their accessories, you can update the stored data accordingly. This approach enables you to serialize the accessory data from your custom storage system when necessary.
Utilizing Roblox’s Data Store service is another viable option. By storing information about each player’s equipped accessories in the data store, you can easily retrieve and serialize the accessory data when needed. This method ensures data persistence and facilitates synchronization across servers.
If AccessoryBlob is accessible on the client but not on the server, you might consider implementing a system where the client sends the necessary accessory information to the server for serialization. However, it’s crucial to implement robust security measures to prevent exploitation.
Lastly, exploring third-party APIs or services that provide information about Roblox accessories could offer additional avenues. These APIs may offer endpoints to retrieve accessory details based on their Asset IDs, providing an external source of accessory information.
Depending on your specific requirements and constraints, one or a combination of these methods should help you effectively serialize accessories, including layered clothing, for your outfit game. Ensure to consider factors such as security, efficiency, and compatibility with Roblox’s terms of service when implementing these solutions.
I appreciate the ChatGPT answer but
Marketplace approach requires me to have the id in the first place which is the main issue I’m having (getting the said id)
the custom data storage thing you recommended wouldn’t work either because the player doesn’t equip the accessories in the game.
I don’t know what you mean by the datastore recommendation
and lastly accessoryblob isn’t accessible on client code either, it’s inaccessible by lua code in general, whether its server or client.
Sorry for the wait, but I have found a solution although its a bit annoying it works, you must use this code on a server script.
local MarketPlaceService = game:GetService("MarketplaceService")
local Player = game.Players:WaitForChild("YourPlayer")
if Player.Character == nil then
Player.CharacterAdded:Wait()
end
local Character = Player.Character
local Description = Character:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("HumanoidDescription")
local function GetAssetIDFromAccessory(Accessory:Accessory)
local SearchType = Accessory.AccessoryType.Name.."Accessory"
local Assets = string.split(Description[SearchType],",")
for i,v in pairs(Assets) do
if tonumber(v) then
local AssetID = tonumber(v)
local AssetData = MarketPlaceService:GetProductInfo(AssetID,Enum.InfoType.Asset)
local Fetched_AssetName = game:GetService("InsertService"):LoadAsset(AssetData.AssetId):GetChildren()[1].Name
if Fetched_AssetName == Accessory.Name then
return AssetData.AssetId
end
end
end
end
local TargetAccessory = Character:FindFirstChildOfClass("Accessory") -- Change this to whatever
print(GetAssetIDFromAccessory(TargetAccessory)) -- It will print the asset id
This is the same solution I ended up using as well, thanks for the reply.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.