How do i check if someone bought the shirt

Hello,so i make a game that you can test merch and i’m was wondering how can i check if someone bought the shirt because i want after you bought the shirt will appear some confetti’s.Here’s my script:

local assetid = script.Parent.Parent.Parent.ClotheInfo.ShirtBuyID.Value
local cd = script.Parent.ClickDetector

cd.MouseClick:connect(function(player)
 game:GetService("MarketplaceService"):PromptPurchase(player,assetid) 
end)
3 Likes

If you want to determine if a player had bought the product, you’d use the MarketplaceService.PromptPurchaseFinished event, though if you have may of these detectors, the code for the event should be in a separate script. Make sure you account for the 3rd return as it can help determine if they purchased the asset or had closed the prompt

And some recommendation since I feel like you have multiple for these detectors, have a single script go through a folder where all the objects with the clickdetectors handle creation of the MouseClick event and prompting of purchase

3 Likes

You can use MarketplaceService:PlayerOwnsAsset() to check if a player owns an asset (model, shirt, pants, etc.)

Let me see,thanks so much for replay!

2 Likes

Wait how can i connect the mouseclick event from the clickdetector to the purchase?

I’m not sure what you’re trying to do, the mouse click is technically connected already since it prompts the purchase, PromptPurchaseFinished gives you enough stuff (the player who purchased, the id of what was purchased, and if the purchased happened or they closed the prompt) to do something when a prompt happened

Thanks so much is working! :DDDDD

1 Like