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()

Previous Thread :: Next Thread 
AstroCode is not online. AstroCode
Joined: 09 Oct 2009
Total Posts: 1122
20 Sep 2015 09:20 AM
Which is faster:

if part.Parent:FindFirstChild("Something") then
part.Parent.Something:Destroy()
end

Or

pcall(function() part.Parent.Something:Destroy() end)
Report Abuse
OrangeKitten is not online. OrangeKitten
Joined: 12 Jul 2007
Total Posts: 383
20 Sep 2015 09:22 AM
Use the first, pcall is very inefficient when used there
Report Abuse
TickerOfTime is not online. TickerOfTime
Joined: 02 Sep 2012
Total Posts: 2030
20 Sep 2015 09:22 AM
Neither

pcall(game.Players.Destroy, part.Parent.Something)
Report Abuse
AstroCode is not online. AstroCode
Joined: 09 Oct 2009
Total Posts: 1122
20 Sep 2015 09:28 AM
@TickerOfTime

What are you talking about? I didn't say anything about game.Players
Report Abuse
TickerOfTime is not online. TickerOfTime
Joined: 02 Sep 2012
Total Posts: 2030
20 Sep 2015 09:39 AM
Ik, but Destroy is a method. Calling it from an existing object is faster than making a new function for pcall, albeit marginally
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
20 Sep 2015 09:40 AM
First one is more efficient, use pcall when it's needed (which is typically never, unless you're using it for a hacky solution).
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
20 Sep 2015 09:41 AM
Also, if you wanted to make your if statement more efficient just do:
local obj = place:FindFirstChild("name");
if obj then
obj:Destroy();
end
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