it will work when you press it, but it does not give you cash. can you make it so it will give you cash
local productId = 726721893 local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() script.Parent:FindFirstChild("SelectionPopSound"):Play() game:GetService("MarketplaceService"):PromptPurchase(player, productId) end)
Sorry for the short answer,
local coins = --PATH OF COINS ---when purchase coins = coins + 1000
So I have my own thing like this and it can do multiple.
---Script goes in ServerScriptService---
local MarketplaceService = game:GetService("MarketplaceService") local Products = { [0]=function(receipt,player) ---Product Id player.leaderstats.Cash.Value = player.leaderstats.coin.Value +10 end; [0]=function(receipt,player) ---Product Id player.leaderstats.Cash.Value = player.leaderstats.coin.Value +25 end; [0]=function(receipt,player) ---Product Id player.leaderstats.Cash.Value = player.leaderstats.coin.Value +40 end; [0]=function(receipt,player) ---Product Id player.leaderstats.Cash.Value = player.leaderstats.coin.Value +60 end; [0]=function(receipt,player) ---Product Id player.leaderstats.Cash.Value = player.leaderstats.coin.Value +400 end; [0]=function(receipt,player) ---Product Id player.leaderstats.Cash.Value = player.leaderstats.coin.Value +1000 end; [0]=function(receipt,player) ---Product Id player.leaderstats.Cash.Value = player.leaderstats.coin.Value +10000 end; [0]=function(receipt,player) ---Product Id player.leaderstats.Cash.Value = player.leaderstats.coin.Value +50000 end; } function MarketplaceService.ProcessReceipt(receiptinfo) local playerProductKey = receiptinfo.PlayerId..":"..receiptinfo.PurchaseId local plr = game:GetService("Players"):GetPlayerByUserId(receiptinfo.PlayerId) local handler for ProductId,func in pairs(Products) do if ProductId == receiptinfo.ProductId then handler = func break end end local suc = pcall(handler,receiptinfo,plr) return Enum.ProductPurchaseDecision.PurchaseGranted end
---Script for the Gui Button---
script.Parent.MouseButton1Click:Connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer,0) --- the product ID end)