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

devproducts isn't loading and buys dont fire response?

Asked by 5 years ago
Edited 5 years ago

After a time debugging a code to prompt a devproduct purchase in my game, i noted the following error right on connection, even in a place of the game with no code involving devproducts purchases:

Model.MainModule:701: attemp to index field 'DevProducts' (a nil value) edit: a image of the error: https://imgur.com/a/ZRo58Hk

The prompt itself is working, the devproduct can be buyed, but the response when a player buys isnt launched; neither with .PromptPurchaseFinished or .ProcessReceipt https://imgur.com/a/05Mb5Kg

can anyone confirm if devproducts are working fine, or can put a tut or something? i've followed the official wiki and a pair of yt tutorials with no result. Thank you

edit: the code actually have this form:

---[[ this code is on a part with a click detector ]]--
local code = 384995071
local market = game:GetService("MarketplaceService")
local playerIn = nil

--code to prompt the buy
script.Parent.ClickDetector.MouseClick:connect(function(player)
    if (player ~=nil) then
        game:GetService("MarketplaceService"):PromptProductPurchase(player, code )
        playerIn = player
    end
end)
---[[ this code is on a part in workspace ]]--
local MarketplaceService = game:GetService("MarketplaceService")
local devproductid = 384995071

--locales
local cofre = game.ReplicatedStorage.Treasures["Robux Chest 10k"]
local PlayerStatManager = require(game.ServerStorage.DataStoreAnimals)


-- Set the callback; this can only be done once by one Script on the server! 
MarketplaceService.ProcessReceipt = function(receiptInfo)
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
            if receiptInfo.ProductId == devproductid then
                print("si comprado")
                --give things to player
            end
        end
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end
0
devproducts are working as they should. Can you include both of your scripts in a code block. User#5423 17 — 5y
0
sure, i have added to the main question cKolmos 0 — 5y
View all comments (6 more)
0
i've already tried with ProcessReceipt but without result. I think the problem may come from that error showed right at entering the game: https://imgur.com/a/ZRo58Hk cKolmos 0 — 5y
0
Can you include the part of the code the error is from. User#5423 17 — 5y
0
sure; i have put the actual form of the code; 1 script in a part with a click detector, to prompt the purchase, and another script in the workspace to act as a purchaseController cKolmos 0 — 5y
0
That code looks ok. But you should return PurchaseGranted after processing the item correctly and not by default. User#5423 17 — 5y
0
ok, i'll keep trying. THank you :D cKolmos 0 — 5y

Answer this question