How would I get gear's attributes?

Hello,

Getting straight to the point, how do I get the attributes of a gear within a script?

I am talking about these attributes, which are visible on the site, I want the players of my game to be able to insert gears, but not all gears? Is there even a way for me to get gear Attributes using a script?

game.MarketplaceService:GetProductInfo() didn’t help.

1 Like

I looked around at the documentation and could only find the following.

https://developer.roblox.com/en-us/api-reference/enum/GearType

It isn’t in use anymore & it was used to determine what gear types were allowed in games.

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

local baseUrl = "https://www.roproxy.com/catalog/%d/%s"

local function getGearAttribute(gearId, gearName)
	gearName = gearName:gsub("%s", "-")
	local gearUrl = baseUrl:format(gearId, gearName)
	local success, result = pcall(function()
		return http:GetAsync(gearUrl)
	end)
	
	if success then
		if result then
			local gearAttribute = result:match("icon%-(%w+%s?%w+)%sattribute%-icon")
			return gearAttribute
		end
	else
		warn(result)
	end
end

local function getProductInfo(productId)
	local success, result = pcall(function()
		return marketplace:GetProductInfo(productId)
	end)
	
	if success then
		if result then
			if result.AssetTypeId == 19 then
				return getGearAttribute(productId, result.Name)
			end
		end
	else
		warn(result)
	end
end

local gearId = 11563251
local gearAttribute = getProductInfo(gearId)
print(gearAttribute) --Explosive.

Here you go, I just wrote this script which gets a gear’s attribute.

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

local baseUrl = "https://www.roproxy.com/catalog/%d/%s"

local function getGearAttributes(gearId, gearName)
	gearName = gearName:gsub("%s", "-")
	local gearUrl = baseUrl:format(gearId, gearName)
	local success, result = pcall(function()
		return http:GetAsync(gearUrl)
	end)
	
	if success then
		if result then
			local gearAttributes = {}
			for gearAttribute in result:gmatch("icon%-(%w+)%sattribute%-icon") do
				table.insert(gearAttributes, gearAttribute)
			end
			return gearAttributes
		end
	else
		warn(result)
	end
end

local function getProductInfo(productId)
	local success, result = pcall(function()
		return marketplace:GetProductInfo(productId)
	end)
	
	if success then
		if result then
			if result.AssetTypeId == 19 then
				return getGearAttributes(productId, result.Name)
			end
		end
	else
		warn(result)
	end
end

local gearId = 15932306
local gearAttributes = getProductInfo(gearId)
print(table.concat(gearAttributes, " ")) --Explosive PowerUp.

Just decided to write a second implementation which supports gears with multiple attributes.

The following is an example of a gear with two attributes.
https://www.roblox.com/catalog/15932306/Starblox-Latte

1 Like

Woah, thank you very much for taking the time to do all this…!

I can’t believe that Roblox doesn’t have an official way of getting gear attributes.