|
| 31 Dec 2012 10:25 AM |
script.Parent.Handle.Touched:connect(function(hit) pcall(function() player = game.Players:getPlayerFromCharacter(hit.Parent) script.Parent:Clone().Parent = player.Backpack script.Parent:Remove() end) end)
Can someone just give me a brief understanding of what the pcall(function()'s use it? |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 31 Dec 2012 10:26 AM |
| You mean what's use of it? It will check if function that you input in it has any errors, and if so, it will return error that occurred. |
|
|
| Report Abuse |
|
|
Luc599345
|
  |
| Joined: 25 Jul 2008 |
| Total Posts: 1169 |
|
|
| 31 Dec 2012 10:31 AM |
| And it if it did error, it won't stop your script. And I don't think I have to mention this, but, it does run the function you pass. |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2012 10:37 AM |
| So in this case, its running the script, and if there are any errors, it ignores them and reruns the script? |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
|
| 31 Dec 2012 10:38 AM |
| It doesn't really "rerun" the script. It only ignores the errors. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 31 Dec 2012 10:39 AM |
| Didn't it return error, in case if it had error? |
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
| |
|
|
| 31 Dec 2012 10:47 AM |
| Does using pcall take up more cpu usage (make lag if used too much), making it better to stick with if statements unless i'm returning anything? |
|
|
| Report Abuse |
|
|
eJorge
|
  |
| Joined: 09 Jun 2011 |
| Total Posts: 5966 |
|
|
| 31 Dec 2012 11:08 AM |
| Conditional statements are more efficient, but I use pcall when I'm too lazy. |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2012 11:11 AM |
I knew that someone would say, I just knew it. I really did know it. I'm used to you scripters <3 |
|
|
| Report Abuse |
|
|