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

Making a dev product but it dosen't work? Closed (Reason: To hard lol)

Asked by 5 years ago
Edited 5 years ago

So i made a dev product (UI) but i can't get "ProcessReceipt" in a local script so i so i used a remote event but it says

"Receipt info a nil value" (in regular script)

and i don't know how to fix it

script in workspace (regular) btw. code: (script in worksace) V

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()

local market = game:GetService("MarketplaceService")





function market:ProcessReceipt(ReceiptInfo)

local player = game.Players:GetPlayerByUserId(ReceiptInfo.PlayerId)

if ReceiptInfo.ProductId == 12345 then

player.Character.Humanoid.WalkSpeed = 50

end

end

end)

local script under text button (remote event in ReplicatedStorage) btw.

local Player = game.Players.LocalPlayer

    local id = 12345

    local market = game:GetService("MarketplaceService")

    local rem = game.ReplicatedStorage.RemoteEvent



    script.parent.TextButton.MouseButton1Click:Connect(function()

    market:PromptProductPurchase(Player,id)

    game.ReplicatedStorage.RemoteEvent:FireServer()

    end)
0
Why on earth are you making a method of the same name as the MarketplaceService's callback? That literally makes no sense. DeceptiveCaster 3761 — 5y
0
It's just odd to assign to a service's property; this is the only time I know of where it's the correct api use. Pretty sure this syntax is valid unless it's expecting no self internally. InfinityDesign 280 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Your first problem is that the MarketplaceService.ProcessReceipt assignment happens inside a RemoteEvent callback.

From the ProcessReceipt page, in bright yellow:

As with all callbacks, this function should be set once and only once by a single [Script](https://developer.roblox.com/api-reference/class/Script). If you're selling multiple products in your game, this callback must handle receipts for all of them.

then again in the sample code:

-- Set the callback; this can only be done once by one script on the server!
MarketplaceService.ProcessReceipt = processReceipt

The possible second problem is the syntax you used. The example is assigned with a dot notation; not a colon.

local function processReceipt(receiptInfo)
    -- do what you need with receiptInfo
end

MarketplaceService.ProcessReceipt = processReceipt
Ad

Answer this question