Kepie
|
  |
| Joined: 12 Nov 2011 |
| Total Posts: 884 |
|
| |
|
Kepie
|
  |
| Joined: 12 Nov 2011 |
| Total Posts: 884 |
|
| |
|
| |
|
|
| 03 Jul 2012 09:08 AM |
pcall
pcall (f, arg1, ···) Calls function f with the given arguments in protected mode. This means that any error inside f is not propagated; instead, pcall catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, pcall also returns all results from the call, after this first result. In case of any error, pcall returns false plus the error message.
if pcall (function() print("Hi Mom!") end) then -- Stuff else print("There were errors") end
if pcall (function() ppppprint("Hi Mom!") end) then -- Stuff else print("There were errors") end
Output: Hi Mom! There were errors
NOTE: You cannot use a function that yields the running coroutine in use by pcall. That includes the wait function. You will get an error about not being able to resume a dead coroutine and not being able to yield across the C boundary. |
|
|
| Report Abuse |
|
|
Ellieb
|
  |
| Joined: 27 Feb 2007 |
| Total Posts: 52 |
|
|
| 03 Jul 2012 09:11 AM |
| pcall basically runs the script or function without error, pcall(function() workspace.Mom:remove() print'a' end) if Mom isn't there it would not error, and print a |
|
|
| Report Abuse |
|
|