Working on an Avatar Editor. I have a HumanoidDescription on the client that I need to send and apply from the server.
I’m not able to send the instance directly through the event, so I would have to create some sort of serializer. The first thing that came to mind was looping the properties, storing them in a table, and just sending the table. I then realized … there is no way to loop the properties.
I could also create a table with all the properties I want to search for, and look specifically for those, but on something like HumanoidDescription (which has 20+ properties), that can get … interesting.
What’s the best way to go about this?
1 Like
Just serialize the properties into a dictionary.
1 Like
That’s my entire question. What is the best way to do it?
By using a dictionary. Literally all you need to do is in my OP. Just define the name of the property as the key and the value as the actual value of the property. Then when you load the properties into a new HumanoidDescription you iterate over the array and fill in the propreties.
-- saving
local SomeDescription = ...
local Description = {
BackAccessory = SomeDescription.BackAccessory,
BodyTypeScale = SomeDescription.BodyTypeScale,
... = ...
}
-- loading
local HumanoidDescription = Instance.new("HumanoidDescription")
for Property, Value in pairs(Description) do
HumanoidDescription[Property] = Value
end
1 Like