How do I use erorr()?

I’m very confused. Isn’t error("") supposed to print a red message to console?

image

This just doesn’t do anything. “A” gets printed and the thread stops running when error() is called but the error message I want to be printed isn’t printed.

1 Like

error() is made to stop the execution and report a specific issue, such as if you don’t intend to have a different type for a specific item as you’ve shown.

I’d usually avoid using it without pcall().

2 Likes

yes, thats what I want it to do. But it doesn’t print the error message to console like it should. It just stops the execution and doesn’t print the error message.

1 Like

woops i found the solution
… it was in a pcall

3 Likes

If you’d like to error and continue the thread. Spawn the piece of code. This will execute the code without interrupting the current thread.

I’m on mobile so this is psuedo code

—code here
spawn(function()
error(“error”)
end)
—code here
1 Like

thank u! :slight_smile:
That helps because I have a large chunk of code pcall’d due to being in a loop, but it helps to be able to see the exact line(s) that an error occurs on

1 Like

No problem. Please mark your thread as fixed if your problem has been fixed.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.