Since I’m currently making a game where you can buy avatar items from characters, I’m using a “HumanoidDescription”. I did this with a very simple script. But I want to know how to get the Outfit ID of each Avatar Item. I want to have an IntValue in the handle of the avatar item, which has the Outfit ID as the Value.
for _, placeAccessories in pairs(avatars:GetChildren()) do
if placeAccessories:FindFirstChild("HumanoidDescription") then
local proximityPrompt = placeAccessories.Spawn.ProximityPrompt
local humDescription = placeAccessories:FindFirstChild("HumanoidDescription")
local hum = placeAccessories.Dummy.Humanoid
hum:ApplyDescription(humDescription)
local accessories = hum:GetAccessories(true)
proximityPrompt.Triggered:Connect(function(plr)
replicatedStorage.RemoteEvents.AvatarItemFrame:FireClient(plr, accessories)
end)
end
end
You already sent the necessary information to the client (the returned array from :GetAccessories()). I’m assuming you’re wanting to create ImageButtons that, when clicked on, prompt the user to buy the asset. If that is the case, there’s no need to create IntValues containing the asset id inside of the accessory’s handle as the array already gives you that information:
-- Example
-- Local Script
local marketPlaceService = game:GetService("MarketPlaceService")
local players = game:GetService("Players")
local player = players.LocalPlayer
-- In the function tied to the OnClientEvent
for _, accessory in (accessories) do
local imageButton = Instance.new("ImageButton") -- Or if you clone a template
-- Changing imagebutton properties
imageButton.MouseButton1Click:Connect(function()
MarketplaceService:PromptPurchase(player, accessory.AssetId)
end)
end