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 » Scripting Helpers
Home Search
 

Re: Pcall Issue

Previous Thread :: Next Thread 
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
03 Dec 2013 09:04 AM
Sorry of that first one, I didn't realised I blocked it.


When I do this it errors:
pcall(function()
Object[2](Player, Message)
end)

When I do this, it doesn't:
Object[2](Player, Message)


What am I doing wrong?
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
03 Dec 2013 09:11 AM
put print( in front of it so you can see the actual error :D
Report Abuse
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
03 Dec 2013 09:13 AM
Why wouldn't it work when I use pcall?
Report Abuse
einsteinK is not online. einsteinK
Joined: 22 May 2011
Total Posts: 1015
03 Dec 2013 09:17 AM
pcall will execute the code.
if the code error, pcall itself will "catch the error".
thuss, pcall returns:
if code worked: true
if code failed: false, "ERROR"

By printing it you'll see if there was any error
Report Abuse
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
03 Dec 2013 09:19 AM
There isn't any error, because when I execute it without pcall, it works fine.
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
03 Dec 2013 09:35 AM
Then why not just avoid the pcall? Don't use pcall unless you absolutely have to.
Report Abuse
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
03 Dec 2013 09:36 AM
I currently do not need it, but it might be needed later on. I'll avoid it for now.
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
03 Dec 2013 09:38 AM
It kinda falls under the 'try/catch' abuse of other languages that some programmers get into bad habits with:

You should be writing your code so it works. Wrapping it with a protective cover is not an excuse to write bad code.

Not saying you're writing bad code :P but pcall should be used only if absolutely necessary
Report Abuse
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
03 Dec 2013 09:41 AM
Yhea, I was making voice commands. But I was thinking 'what if someone enters something that breaks the script? nothing would work anymore!'

So, that's why.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
03 Dec 2013 10:41 AM
What happens if you use this:


pcall(Object[2], Player, Message)



Just curious. I'd like to find out why that statement is erroring for you.
Is your Object[2] function yielding at all?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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