Hello!
I am assuming the issue here lies simply in the Functions
you are using via the MarketplaceService.
I did some organizing & redoing of your code!
I'm assuming that you are prompting purchase of a Developer Product or a Game Pass (within the game), so here is the code that should work for that.
02 | local marketplaceService = game:GetService( 'MarketplaceService' ) |
03 | local productId = 1086368295 |
05 | local part = workspace:WaitForChild( 'SellCoins1000' ) |
06 | local button = part:WaitForChild( 'Buy1000' ) |
11 | local function promptPurchase(player) |
12 | if not marketplaceService:UserOwnsGamePassAsync(player.UserId, productId) then |
13 | marketplaceService:PromptGamePassPurchase(player, productId) |
14 | marketplaceService.PromptGamePassPurchaseFinished:Connect( function (player, purchasedId, bought) |
15 | if purchasedId = = productId and bought = = true then |
16 | print (player .. 'has successfully purchased something!' ) |
17 | player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + statsGain |