How to use pcall()?

hi, i was wordering how to use pcall(arguments)? becouse i know only how to use pcall(function() end) but not pcall(arguments) how can i use that? Becouse on roblox wiki at Marketplace.ProcesReceipt contains this: local succes,result = pcall(func,DevInfo,Player)


pcall(function, arg1, arg2, ...) can take multiple arguments, and the first one should be the function to execute.
The way it works is that all the arguments you pass after the function, in your case the DevInfo and Player are then passed to the function being executed. For example:

pcall(function(string1, string2) print(string1, string2) end), 'hello', 'hi')

would then print both ‘hello’ and ‘hi’.


but without any function how it works?

1 Like

You must pass a function as the first argument, otherwise it wont work.
pcall is used for error handling. It will execute the function, and if the function errors, it will handle it and give you the error, rather than erroring in your main thread and stopping.

The example you provided does pass a function as the first argument, func, and then the DevInfo and Player as extra arguments.


Hello may I have an example of how I would use a pcall to create a speed gamepass… Would really help and can it be used in the same manner for other passes?