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

Why wont my script work? [Not solved]

Asked by 9 years ago

I have got this for my developer product to add 5000 cash but it wont work please help.

id = 20566241 --dev product id

script.Parent.MouseButton1Click:connect(function()
    game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, id)
    local MarketplaceService = Game:GetService("MarketplaceService")
    local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
    MarketplaceService.ProcessReceipt = function(receiptInfo) 
        if game.Players.LocalPlayer.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == id then
                game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value + 5000
            end
        end 

    -- record the transaction in a Data Store
    local playerProductKey = receiptInfo.PlayerId .. "_got_" .. receiptInfo.PurchaseId
    ds:IncrementAsync(playerProductKey, 1)  

    -- tell ROBLOX that we have successfully handled the transaction
    return Enum.ProductPurchaseDecision.PurchaseGranted     
    end
end)

The error is that it wont give me the 5000 cash and I have to reset to buy it again.

1 answer

Log in to vote
0
Answered by 9 years ago

This needs to be in a local script inside a GUI within your game, not a regular script. I'm not sure if its already in a local script or not but at first glance seems the most likely error

0
Oh ok someone told me a regular danieln101111 0 — 9y
0
game.Players.LocalPlayer can only be called from a LocalScript. Thats the tell-tale sign MasterDaniel 320 — 9y
0
I will come back and say if it works danieln101111 0 — 9y
0
Ok so it said it wouldn't work because roblox is performing matanence why is this? danieln101111 0 — 9y
View all comments (3 more)
0
It still wont work any help? danieln101111 0 — 9y
0
If it says ROBLOX is performing maintenance it means that your trying to buy a developer product from another place. Are you sure this developer product id is for the developer product in your place? MasterDaniel 320 — 9y
0
Yes I mistyped the Dev Id I have it working now thanks! danieln101111 0 — 9y
Ad

Answer this question