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

Value doesn't change after buying Developer Product?

Asked by 4 years ago

This is my button script:

local player = game.Players.LocalPlayer
local Market = game:GetService("MarketplaceService")
id = 984081930

script.Parent.MouseButton1Click:Connect(function()
    Market:PromptProductPurchase(player,id)
end)

This is my serverscript:

local Market = game:GetService("MarketplaceService")

Market.ProcessReceipt = function(receiptInfo)
    if receiptInfo.ProductId == "984081930" then
        game.Workspace.InvincibilityActivated.Value = false
        print("Activated!")
        wait(30)
        game.Workspace.InvincibilityActivated.Value = true
        print("Expired")
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end

It doesn't seem to change the Value.

1 answer

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
4 years ago

I guess heres a fixed serverscript?

local MarketplaceService = Game:GetService("MarketplaceService")

local P1 = 984081930

MarketplaceService.ProcessReceipt = function(receiptInfo)
    local Player = Game.Players:GetChildren()
    for i = 1, #Player do
        if Player[i].userId == receiptInfo.PlayerId then
            prodId = tonumber(receiptInfo.ProductId)
            if prodId == P1 then
                game.Workspace.InvincibilityActivated.Value = false
                    print("Activated!")
                    wait(30)
                    game.Workspace.InvincibilityActivated.Value = true
                    print("Expired")
            else
                --Error
            end
        end
    end

    return Enum.ProductPurchaseDecision.PurchaseGranted
end
0
Could you give me an explanation? CrypxticDoge 135 — 4y
0
Not very good at that. Lakodex 711 — 4y
Ad

Answer this question