#whats wrong?

1 messages · Page 1 of 1 (latest)

light crest
#
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local ProductToQuantity = {
    [3296774010] = 25000,
    [3296774101] = 100000,
    [3296774225] = 250000,
}

MarketplaceService.ProcessReceipt = function(receiptInfo)
    local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
    if not player then
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end

    local leaderstats = player:FindFirstChild("leaderstats")
    if not leaderstats then
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end

    local money = leaderstats:FindFirstChild("Money")
    if not money then
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end

    local quantity = ProductToQuantity[receiptInfo.ProductId]
    if quantity then
        money.Value = money.Value + quantity
    end

    return Enum.ProductPurchaseDecision.PurchaseGranted
end

the prompting is handled on the client with a ui button (already working)

#
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local ProductToQuantity = {
    [3296774010] = 25000,
    [3296774101] = 100000,
    [3296774225] = 250000,
}

MarketplaceService.ProcessReceipt = function(receiptInfo)
    print("ProcessReceipt called with ProductId:", receiptInfo.ProductId)

    local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
    if not player then
        print("Player not found for UserId:", receiptInfo.PlayerId)
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end

    local leaderstats = player:FindFirstChild("leaderstats")
    if not leaderstats then
        print("Leaderstats not found for player:", player.Name)
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end

    local money = leaderstats:FindFirstChild("Money")
    if not money then
        print("Money stat not found in leaderstats")
        return Enum.ProductPurchaseDecision.NotProcessedYet
    end

    local quantity = ProductToQuantity[receiptInfo.ProductId]
    if quantity then
        print("Adding", quantity, "to", player.Name)
        money.Value = money.Value + quantity
    else
        print("Unknown ProductId:", receiptInfo.ProductId)
    end

    return Enum.ProductPurchaseDecision.PurchaseGranted
end

this script only lets me buy it once, after that nothing happens

light crest
#

I would appreciate any help because I have no clue why it’s not working

haughty sedge
light crest
#

No not at all

restive swallowBOT
#

studio** You are now Level 3! **studio