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

Script only awarding points on rejoin of new servers?

Asked by
lomo0987 250 Moderation Voter
10 years ago

The script only provides the player point after they rejoin a new server. I was wondering if there is anything wrong with the script? It's currently placed within the ServerScriptStorage.

local MarketplaceService = game:GetService("MarketplaceService")
local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
local points = game:GetService("PointsService")
local testpoints = 19280588


MarketplaceService.ProcessReceipt = function(receiptInfo)
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.userId == receiptInfo.PlayerId then
    print("Well, lets start!")
           if receiptInfo.ProductId == testpoints then
                points:AwardPoints(player.userId, 1)

    print("Transaction Was seccesful_" .. receiptInfo.PlayerId)
            end
        end
    end    
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
    ds:IncrementAsync(playerProductKey, 1) 
    return Enum.ProductPurchaseDecision.PurchaseGranted    
end

Answer this question