Failed to get asset cost for ID?

I’ve tried different methods but for some reason I can’t get the robux cost of the player’s asset. I’m making an asset tipping system where players can get their own shirts/pants/etc. and have it to be their donation options.

local function getProductCost(assetId)
	local productInfo = MarketplaceService:GetProductInfo(assetId, Enum.InfoType.Asset)
	if productInfo and productInfo.PriceInRobux then
		return productInfo.PriceInRobux
	else
		warn("Failed to get asset cost for asset ID:", assetId)
		return "N/A"
	end
end

--[Announcement Handler]
game.ReplicatedStorage.Donation_Announce.OnClientEvent:Connect(function(assetId, donator, recipient, announcement_type)
	if announcement_type == "Major" then
		print("Major Donation")
		-- Hide necessary UIs
		script.Parent.Frame.Visible = false
		script.Parent.Parent.PlayerAssetsTip.MyAssets.Visible = false

		local frame = script.Parent.Donate_Announcement.Major
		local getID = game.Players:FindFirstChild(donator)
		frame.Avatar_Icon.Image = "rbxthumb://type=Avatar&id=" .. getID.UserId .. "&w=150&h=150"
		frame.Visible = true
		frame.Amount.Text = getProductCost(assetId) .. " Robux"
		frame.TextLabel.Text = donator .. " has donated to " .. recipient
		frame:TweenPosition(UDim2.new(0, 0, 0, 0))
		task.wait(4)
		frame:TweenPosition(UDim2.new(1, 0, 0, 0))
		task.wait(1)
		frame.Visible = false
		frame:TweenPosition(UDim2.new(-1, 0, 0, 0))

	elseif announcement_type == "Minor" then

Snippet of my code, keep in mind I’ve debugged this and the “AssetId” parameter is a valid ID, it’s just for some reason I can’t get the robux cost of said ID.

2 Likes

Kind of confused, Assets are Models which are free.

2 Likes

My bad, assets as in the shirts/pants/tshirts the player owns in which they have published to the roblox catalog

1 Like

Oh my bad actually, I forgot shirts were assets

Here is another post that can help PriceInRobux not working on shirts

Have you tested this out in the game itself?

Yep, doesn’t display the robux cost on the textlabel

Tried that solution into my code and no luck

You should be able to get the access PriceInRobux key returned from MarketplaceService:GetProductInfo(), as long as the asset of the assetid is not free.

Using assetid of a free asset:

Using assetid of an asset that costs robux:

Figured it out, after debugging the code and printing the “AssetId” throughout I saw it changed when it started firing the PurchaseId instead of the AssetId to the client

I have not did a tip system yet.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.