I'm making a GUI where you click a button and if you own the shirt then it will give you an item, and if you don't own it, it will prompt a purchase.
local ASSET_ID = 123456 --Asset Id here
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local PlayerOwnsAsset = MarketplaceService.PlayerOwnsAsset
script.Parent.MouseButton1Click:Connect(function(player)
local success, doesPlayerOwnAsset = pcall(PlayerOwnsAsset, MarketplaceService, player, ASSET_ID)
if doesPlayerOwnAsset then
local clone = game.ReplicatedStorage.item:Clone()
clone.Parent = player.Backpack
else
game:GetService("MarketplaceService"):PromptProductPurchase(player, ASSET_ID)
end
end)

2 comments
What part of your script is the issue? Does it nit give the item? Does it not prompt the purchase?
It says "Attempt to index "Nil" with backpack"