How would I be able to find the items in a players inventory

Hey there! I’m working on a game with my friend @Adambaked . We basically need a script to find out items in a players inventory. (By items I mean hats, shirts, pants, etc.) The only problem is, we have no idea how to do it. I’ve though about using the https://avatar.roblox.com/docs#!/Avatar/get_v1_users_userId_avatar but I honestly have no idea. Any help is appreciated, thanks!

2 Likes

I was gonna say to loop through the Player’s Backpack but thank heavens I re-read the post

Couldn’t you just loop through the Character’s Children, and check if the Object is a “Hat”, “Shirt”, “Pants”, or “Accessory”? You’d need to reference the Character in some way though

local Items = 0

for _, Object in pairs(Character:GetChildren()) do
    if Object:IsA("Pants") or Object:IsA("Accessory") or Object:IsA("Shirt") then --You can add more to expand what you want to search
        Items += 1
    end
end

print(Character.Name.." has "..Items.." items in their inventory")

You would probably want to use the inventory API (if the player has a private inventory, you won’t be able to see their assets)
https://inventory.roblox.com/docs#/

Instead of this, is there anyway I could get the items on a GUI with pictures of them? sorry im not a scripter

You could reference each of their individual Asset ID’s, then insert them into the GUI depending on how much items there are using a UIConstraint/UILayout object of some sort

https://developer.roblox.com/en-us/articles/Content

Not sure though

1 Like