Currently my character customisation has hats and hairs. Works great. However, I wanna add more accessory types, and my original plan was to just have ‘accessories’ be like accessories that aren’t hats or hairs.
However, I’d run into the problem of distiguishing each item when setting the HumanoidDescription.
-- How I set the Hat accessories
HumanoidDescription.HatAccessory = table.concat(User.Character.HatAccessories, ', ')
So User.Character.HatAccessories
is just a table with the ID’s of their equipped hats. Then I had a table for their future accessories
User.Character.Accessories = {} -- and I was gonna store their other accessories here
However, the HumanoidDescription is specific on what ID’s go where, as ‘Accessories’ would be
|BackAccessory||
|FaceAccessory||
|FrontAccessory||
|NeckAccessory||
|ShouldersAccessory||
|WaistAccessory|
But I don’t really wanna have a seperate data store for EACH of these different accessories, I kinda just wanna store them all in the one. But then how can I assign the IDs from User.Character.Accessories
to the specific HumanoidDescription property
Each accessory ID could be in a dictionary, along with it’s type like:
local t = {
Type = "Face",
Id = "rbxassetid://0"
}
Then when you go to set their HumanoidDescription you could loop through, check it’s type and apply it:
User.Character.Accessories = {}
table.insert(User.Character.Accessories, {
Type = "Face",
Id = "rbxassetid://0"
})
for _, v in pairs(User.Character.Accessories) do
if v.Type == "Face" then
HumanoidDescription.FaceAccessory = v.Id
end
--etc
end
A more “simpler” approach would be to go by Modules, for example.
Creating a folder and creating a module per accessory category, like faces, hats, skin, etc.
What I’d do is;
return {
Human = {[1] = “Light orange”, [2] = “Buttermilk”, [3] = “Khaki”, [4] = “Brick yellow”, [5] = “Beige”, [6] = “Cashmere”, [7] = “Pastel brown”, [8] = “Wheat”, [9] = “Burlap”, [10] = “Nougat”, [12] = “Brown”, [13] = “Reddish brown”, [14] = “Pine Cone”, [15] = “Dark taupe”, [16] = “Dirt brown”}
)
As human colors.
COLOR, NUMBER.
Please do correct me if I am not understanding what you are trying to achieve.
Figured out a solution that works for my case. Not sure if it’s the cleanest way to go about it, but it works
local FaceAccessory = {}
local NeckAccessory = {}
local ShoulderAccessory = {}
local FrontAccessory = {}
local BackAccessory = {}
local WaistAccessory= {}
for _, v in pairs(User.Character.Accessories) do
local AssetTypeId = MarketplaceService:GetProductInfo(v).AssetTypeId
if AssetTypeId == 42 then
table.insert(FaceAccessory, v)
elseif AssetTypeId == 43 then
table.insert(NeckAccessory, v)
elseif AssetTypeId == 44 then
table.insert(ShoulderAccessory, v)
elseif AssetTypeId == 45 then
table.insert(FrontAccessory, v)
elseif AssetTypeId == 46 then
table.insert(BackAccessory, v)
elseif AssetTypeId == 47 then
table.insert(WaistAccessory, v)
end
end
HumanoidDescription.FaceAccessory = table.concat(FaceAccessory, ', ')
HumanoidDescription.NeckAccessory = table.concat(NeckAccessory, ', ')
HumanoidDescription.ShouldersAccessory = table.concat(ShoulderAccessory, ', ')
HumanoidDescription.FrontAccessory = table.concat(FrontAccessory, ', ')
HumanoidDescription.BackAccessory = table.concat(BackAccessory, ', ')
HumanoidDescription.WaistAccessory = table.concat(WaistAccessory, ', ')
2 Likes