pcall

Calls a function and catches any error, returning ok plus the result or the error text.

Think of it as A safety net under a trapeze act: the show goes on if the act falls.

pcall(fn, ...) runs fn in protected mode. It returns true followed by fn's results, or false followed by the error message. Roblox code wraps calls that can fail at run time, such as DataStore requests, in pcall and keeps both return values so the error text can be logged.

Official reference: luau.org

Related terms