How do i get the Players T-shirts, Gamepasses, And Shirts in one script

Hello, I am trying to get a player, T-shirts, Game Passes, And Shirts in one script, but i can’t find a script that works. I have tried a lot of scripts but none of them work.
Does anyone have any script that works for this?
Thanks, MasonX890

3 Likes

What do you mean by “get” their shirts? Do you mean like a GUI that shows all of their shirts and etc. all in one place?

1 Like

Ok, so what I mean is, like in the game Pls Donate, it gets all the players shirts and puts them onto a surface Gui, I know how to put them on a Gui, but i need the script to find the users shirts

1 Like

Are you trying to make a game like Pls Donate? Let the trend die please… :sob:

No, Im not, i need the shirts for something else

I need it to make a clothing change system in my game

You’d need to use a web request to get the player’s inventory. First, enable requests the game game security settings. Then you can use an endpoint to see if the user allows you to see their inventory, then you can use another to get the items in the user’s inventory.

1 Like

Refer to something along the lines of this to get the result desired!

2 Likes

I can’t, I tried to remove the other things that aren’t getting the shirt but it won’t work, I only need to get the Shirts, T-Shirts, etc., not put it on a Gui

This will require HttpService because you cannot send requests to the Roblox API from a Roblox game.

Roblox Inventory API:
https://inventory.roblox.com/docs

1 Like
local http = game:GetService("HttpService")

local function getUserAssetsRecursive(AssetId, userId, assets, pageNumber, lastLength)
	local baseUrl = "https://www.roproxy.com/users/inventory/list-json?assetTypeId="..AssetId.."&cursor=&itemsPerPage=100&pageNumber=%s&userId=%s"

	assets = assets or {}
	pageNumber = pageNumber or 1
	lastLength = lastLength or math.huge

	local requestUrl = baseUrl:format(pageNumber, userId)
	local success, result = pcall(function()
		return http:GetAsync(requestUrl)
	end)
	
	if success then
		if result then
			local success2, result2 = pcall(function()
				return http:JSONDecode(result)
			end)

			if success2 then
				if result2 then
					for _, asset in ipairs(result2.Data.Items) do
						if asset.Creator.Id == userId then
							table.insert(assets, asset.Item.AssetId)
						end
					end

					if result:len() ~= lastLength then
						lastLength = result:len()
						pageNumber += 1
						getUserAssetsRecursive(AssetId,userId, assets, pageNumber, lastLength)
					end
				end
			end
		end
	end
	return assets
end

local function GetUserCreatedAssets(UserId : number,Assets : table)
	local createdAssets = {}
	
	for _,enum in pairs(Assets) do
		local info = getUserAssetsRecursive(enum.Value,UserId)
		createdAssets[enum.Name] = info
	end
	
	return createdAssets
end

local AssetsWanted = {Enum.AssetType.Shirt,Enum.AssetType.Pants,Enum.AssetType.TShirt,Enum.AssetType.GamePass}
local data = GetUserCreatedAssets(302233980,AssetsWanted)

print(data)

--[[
{
	Gamepasses = {}
	Shirts = {}
	TShirt = {}
	Pants = {}
}

--]]
4 Likes

All it prints is table: 0x96ab6c9057ea9458

2 Likes

are you using studio?
image
because it works just fine for me

2 Likes

Yes, I am using studio i just get: table: 0x96ab6c9057ea9458

2 Likes

Hey I tried printing it, but all the content of the tables within shirts, pants, and t shirts are all empty.

3 Likes

If their inventory is hidden, you can not retrieve anything

2 Likes

There was a recursive function i believe.

2 Likes

It does use recursion, but thats not an issue. Check if you have enabled https service

2 Likes

It is enabled, I wish to get all of the shirts, t shirts, and pants even if the player’s inventory is private. This did work with one of the roproxy links, however, it only received one item of the player.

2 Likes

Not really possible, after all thats the idea of “private inventory”

2 Likes