RequestPromptPurchase

Request the server prompt's the user to purchase the developer product, or for a free product this will purchase if allowed.

InvokeServer ('RequestPromptPurchase', ProductId)

Request the server prompt's the user to purchase the developer product, or for a free product this will purchase if allowed. Returns a success boolean and optionally an alert message. If success is true and the alert message is nil, the user was prompted to purchase the developer product. If success is true and the alert message is present, the alert message is the new license ID.

Parameters

Field
Type
Description

ProductId

string

the id of the product to purchase

Example Script

local RS = game.ReplicatedStorage:WaitForChild('InStore');
local RF = RS.Function; --> The InStore RemoteFunction

function PromptPurchase(ProductId)
  local success, message = RF:InvokeServer('RequestPromptPurchase', ProductId);
  if success and message then
    -- User was given a license for this free product. `message` is the new license id
  elseif success and not message then
    -- User was prompted to purchase the developer product.
    -- Usually, you don't need to do anything here. The Alert event will be fired when the purchase processes.
  else
    -- An error occurred or the prompt was declined. `message` is the error message.
  end
end

ProductPurchaseButton.MouseButton1Click:Connect(function()
  PromptPurchase(ProductId); -- You'll need to somehow reference the purchase button to the respective product id
end)

Last updated