generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: pcall help (its small and easy)

Previous Thread :: Next Thread 
MrChickens is not online. MrChickens
Joined: 21 Feb 2009
Total Posts: 1076
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 is not online. 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 is not online. 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
MrChickens is not online. MrChickens
Joined: 21 Feb 2009
Total Posts: 1076
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 is not online. 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 is not online. 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 is not online. 129K
Joined: 23 Aug 2011
Total Posts: 19010
31 Dec 2012 10:40 AM
@zars15

Yes
Report Abuse
MrChickens is not online. MrChickens
Joined: 21 Feb 2009
Total Posts: 1076
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 is not online. 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
MrChickens is not online. MrChickens
Joined: 21 Feb 2009
Total Posts: 1076
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image