Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

i cant make it so it will give you 1k cash?

Asked by
DJH_100 28
4 years ago

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)

0
Could you show a bit more code? Skippy_Development 59 — 4y
0
thats all i have DJH_100 28 — 4y
0
my cash is in the player, and the cash is caled coins DJH_100 28 — 4y
0
Just posted a answer hope it helped Skippy_Development 59 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Sorry for the short answer,

local coins = --PATH OF COINS

---when purchase 

coins = coins + 1000
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
0
thanks DJH_100 28 — 4y

Answer this question