How to make a button that gives tool after buying gamepass

as you can see in the title i want to button that gives gamepass after buying but i dont know how to use PromptPurchaseFinished

2 Likes

Hello!

local MarketplaceService = game:GetService("MarketplaceService")
MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
if isPurchased then
--there just clone your tool to player's backpack
else
print(player.Name .. " didn't buy the gamepass " .. assetId)
end
end)
2 Likes

is service getting player automatically?

Yes the First* 3 parametrs of it are automaticly

Thank you for that code i was searching for days

no problem have a good day :smiley: