I tried to create a game where players can create avatars and then buy them. I also wanted to make it so that you can buy other players’ avatars by clicking on another player and the accessories, hair, and clothes are visible (on a frame in the screengui). But I don’t know if it’s possible to write a script that recognizes the accessories, hair, and clothes the player is wearing and shows the pictures of the items in the frame. Can someone explain to me how to write such a script?
1 Like
You should create a for loop which goes the target character’s descendants, if the value is an accessory, shirt, etc, then store them in a table. After you’ve looped through this I’m pretty sure you’ll need to use veiwport frames to turn these items into guis.
local TargetCharacter -- Character you're targetting
local StorageTable = {
Accessories = {},
Clothing = {},
}
for _,Value in ipairs(TargetCharacter:GetDescendants()) do
if Value:IsA("Accessory") then
table.insert(StorageTable.Accessories, Value)
elseif Value:IsA("Clothing") then
table.insert(StorageTable.Clothing, Value)
end
end
2 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.