Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How is 'error()' used, and what is it used for?

Asked by 10 years ago

I've seen it a few times, but I am not sure what it does and what it is supposed to do, is it like 'print()'? If this Question is not valid, I am sorry.

1 answer

Log in to vote
2
Answered by
war8989 35
10 years ago

Yes, error() is similar to print(), but instead of displaying a message in Output , it throws an error with the string passed to it. You can call the method like so:

error("Hello, this is an error.")

Which can be useful for some reasons, like if the script gets to a point it shouldn't.

Use that line from a Command Line or from a script to see an output similar to this:

Command Line:

21:33:08.172 - error("This is an error message"):1: This is an error message
21:33:08.173 - Script 'error("This is an error message")', Line 1
21:33:08.174 - Stack End

Script:

// I called the error method like this:
error("HELLO")

21:36:02.645 - Workspace.Script:1: HELLO
21:36:02.646 - Script 'Workspace.Script', Line 1
21:36:02.648 - Stack End
0
What would happen if I used it in a 'if' statement? TheeDeathCaster 2368 — 10y
Ad

Answer this question