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)
MouseButton1Click does not return a value so your player
variable will always be nil.
In your LocalScript, you can get the current player by using
game:GetService("Players").LocalPlayer
If you need more info, you can find the documentation for MouseButton1Click here