UGC Purchase Prompt Showing Error

Trying to make a script where the player can buy the UGC and then once they have bought the UGC it would equipped it in-game.

When trying to purchase the UGC, it displays this error

image

Code Snippet:

local Folder = workspace:FindFirstChild("UGC")
local MarketplaceService = game:GetService("MarketplaceService")

if Folder then
	for _, item in ipairs(Folder:GetChildren()) do
		print("I've found: " .. item.Name)

		local WearPrompt = item.Model.PromptAttachment and item.Model.PromptAttachment.WearPrompt
		local BuyPrompt = item.Model.PromptAttachment and item.Model.PromptAttachment.BuyPrompt

		if WearPrompt and BuyPrompt then
			WearPrompt.Triggered:Connect(function(player)
				local character = game.Workspace:FindFirstChild(player.Name)
				if character then
					for _, child in ipairs(character:GetChildren()) do
						if child:IsA("Accessory") and child.Name == "Accessory" then
							child:Destroy()
						end
					end

					local ClonedItem = item.Cloned and item.Cloned.Accessory and item.Cloned.Accessory:Clone()
					if ClonedItem then
						ClonedItem.Parent = character
						ClonedItem.Handle.Anchored = false
						ClonedItem.Handle.Transparency = 0

					end
				end
			end)

			BuyPrompt.Triggered:Connect(function(player)
				local ID = item:FindFirstChild("ID")
				if ID then
					local productId = ID.Value
					MarketplaceService:PromptProductPurchase(player, productId)
				end
			end)
		end
	end
end

Not sure whats making it display the error.

I believe it’s supposed to be MarketplaceService:PromptPurchase for avatar assets

3 Likes

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