local mps = game:GetService("MarketplaceService") game.Players.PlayerAdded:Connect(function(player) game.Workspace.SellCoins1000.SurfaceGui.Buy1000.MouseButton1Click:Connect(function() local productId = 1086368295 game:GetService("MarketplaceService"):PromptProductPurchase(player, productId) mps.ProcessReceipt = function(receiptInfo) if receiptInfo == productId then player(receiptInfo.playerId) player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1000 return Enum.ProductPurchaseDecision.PurchaseGranted end end end) end)
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.
-- Variables: local marketplaceService = game:GetService('MarketplaceService') local productId = 1086368295 local part = workspace:WaitForChild('SellCoins1000') local button = part:WaitForChild('Buy1000') local statsGain = 1000 -- onClicked Function: local function promptPurchase(player) if not marketplaceService:UserOwnsGamePassAsync(player.UserId, productId) then --Making sure the player doesn't already own the game pass marketplaceService:PromptGamePassPurchase(player, productId) marketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedId, bought) if purchasedId == productId and bought == true then print(player .. 'has successfully purchased something!') player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + statsGain end end) end end