I have Two scripts that are suppose to make it so when you click a button it will ask if you want to buy something(with robux), and and when you click to buy it it will add to a leader stat(for the person who bought it).
this script is in ServerScriptService:
local MarketplaceService = game:GetService('MarketplaceService') local devProductid = 391839362 MarketplaceService.ProcessReceipt = function(receiptInfo) for i, player in pairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then player.leaderstats.Coins.Value = player.leaderstats.Coins.Value +100 end end return Enum.ProductPurchaseDecision.PurchaseGranted end
This is in the text button:
local devproductid = 391839362 local button = script.Parent button.MouseButton1Click:Connect(function() game:GetService('MarketplaceService'):PromptProductPurchase(game.Players.LocalPlayer, devproductid) end)