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

Why is it not giving the player the value?

Asked by 10 years ago

When a player buys lets say the +50 player points, it does not give them 50 players points only 2...

I hid the numbers, so yeah please tell me what i'm doing wrong!

Is it because i had the extra comma at ["0"]=500,?

local Service = Game:GetService("PointsService")

local Products={
    ["0"]=2,
    ["0"]=5,
    ["0"]=10,
    ["0"]=50,
    ["0"]=500,
}

local PurchaseHistory = Game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")

Game:GetService("MarketplaceService").ProcessReceipt=function(Receipt)
    local PlayerProductKey = Receipt.PlayerId.."_"..Receipt.PurchaseId
    for _,Player in pairs(Game.Players:GetChildren())do
        if Player.userId==Receipt.PlayerId then
            if PurchaseHistory:GetAsync(PlayerProductKey)then
                return Enum.ProductPurchaseDecision.PurchaseGranted
            end
            for i, v in pairs(Products)do
                if tostring(Receipt.ProductId)==i then
                    Service:AwardPoints(Player.userId, v)
                    PurchaseHistory:SetAsync(PlayerProductKey, true)
                    return Enum.ProductPurchaseDecision.PurchaseGranted
                end
            end
        end
    end
end

1 answer

Log in to vote
0
Answered by
Rukiryo 25
10 years ago

The best way to debug is to print data.

Also, isolate part of your code. Get rid of that purchasehistory stuff. Just strictly award points without logging it. I'm not sure what you're doing with that code. It seems to look if the player has purchased points before, if yes, then it doesn't give them any more? No idea.

Now, make your point giving code print the ID of the product you buy, how many points it should award, etc.

Go ingame , press F9 to open a console, and then see what's up.

0
How could i remove the purchase history safely? peoplemove12 148 — 10y
Ad

Answer this question