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

Why am I not getting information from Marketplace Service? [closed]

Asked by 9 years ago

I'm experimenting with Developer Products, but when I add the .ProcessReceipt, I'm not getting the correct information. PlayerID and ProductID both appear to be nil.

local mps=game:GetService("MarketplaceService")
function getPlayerWithID(id)
    print("Getting player...")
    print("Target player id is "..tostring(id))
    local plrs=game.Players:GetPlayers()
    for i=1,#plrs do
        print("Checking"..plrs[i].Name)
        if plrs[i].userId==id then print("Found player") return plrs[i] end
    end
end
function getValueWithID(id2)
    print("Getting product...")
    print("Target product id is "..tostring(id2))
    local items=game.Workspace.GameInfo.gI_CASH_DATA:GetChildren()
    for j=1,#items do
        if items[j].ProductID.Value==id2 then print("Found product") return items[j].CashValue.Value end
    end
end
mps.ProcessReceipt=(function(info)
    print("Something was purchased")
    print("player id is "..tostring(info.PlayerID))
    print("product id is "..tostring(info.ProductID))
    local plr=getPlayerWithID(info.PlayerID)
    local giveAmount=getValueWithID(info.ProductID)
    wait(1)
    if giveAmount~=nil then
        print("Dispensing cash")
        plr.leaderstats.Cash.Value=plr.leaderstats.Cash.Value+giveAmount
    else
        print("Purchase was not relevant to cash purchases")
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end)

If you would like to view the actual game, here it is: http://www.roblox.com/--place?id=182988661

Thanks for helping out!

EDIT: I figured out what was wrong, ProductID and PlayerID are not the same as ProductId and PlayerId!

Locked by Spongocardo, adark, and M39a9am3R

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?