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
 

Getting Error Message

Previous Thread :: Next Thread 
Rrrrry123 is not online. Rrrrry123
Joined: 23 Nov 2009
Total Posts: 93
28 Dec 2013 05:43 PM
So, I do some C# programming and to get an error message you just do a

try
{
//code
}

catch (Exception ex)
{
Console.WriteLine(ex.Message)
}

and the console prints the error message.

Can I/How would I do that in Roblox Lua?
Report Abuse
jawa280 is not online. jawa280
Joined: 26 Jun 2007
Total Posts: 453
28 Dec 2013 07:45 PM
You can do this using the pcall function

Example:

function test()
pprint("Test!") -- The statement that will cause the error
end

print(pcall(test)) -- will print either true or false, based on if the call succeeds, if false it will print the error

print(pcall(function() pprint("Test!") end)) -- same thing, just one line

assert(pcall(function() pprint("Test!") end)) -- you can use assert for a more "proper" error message

For more information:
http://wiki.roblox.com/index.php/Pcall#pcall
http://wiki.roblox.com/index.php/Assert#assert
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
28 Dec 2013 07:46 PM
That is Lua not C# lol narb
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
28 Dec 2013 07:47 PM
Oh nvm I didn't read it all. It was too long i sowwy
Report Abuse
yoiano2 is not online. yoiano2
Joined: 22 Sep 2007
Total Posts: 522
28 Dec 2013 07:56 PM
Since when can't you ask non-lua related questions? You still can can't you? Or am I just that old...
Report Abuse
Rrrrry123 is not online. Rrrrry123
Joined: 23 Nov 2009
Total Posts: 93
29 Dec 2013 03:59 PM
Thank you very much, jawa280
Report Abuse
yoshimaster240102 is not online. yoshimaster240102
Joined: 14 Apr 2012
Total Posts: 470
29 Dec 2013 04:01 PM
In rblx.lua you canjust do:

Error(msg)
Report Abuse
amazingmoney5 is not online. amazingmoney5
Joined: 26 Apr 2011
Total Posts: 1082
29 Dec 2013 04:02 PM
@yoi
he was talking to the guy
he thought OP wanted C# code but he wanted RBX.Lua code so
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