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 Avatar Api but I honestly have no idea. Any help is appreciated, thanks!


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

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)

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

Not sure though

1 Like