Basic global functions
✏ Beginners Scripting Guide ✏
Last updated
✏ Beginners Scripting Guide ✏
Last updated
In this section, we will be discussing global functions. Global functions were the functions that were built-in in Roblox. You can call them by typing their name in the script and call them. In Roblox, we got assert(), gcinfo(), setmetatables() and much more as Roblox built-in functions. But, we are not talking about them now because we are going to be talking about how print(), warn(), error(), and assert() and how they work in Roblox.
The print() global function can be used to print out the content that was put inside of it into Roblox output. It is very useful when it comes to debugging your code to find what bug caused this glitch or error in your game.
The warn() global function can be used to print out the content that was put inside of it as yellow/orange text into Roblox output. It can be used to get developers' attention so that they can keep track of what their script is doing and adjust a few changes to the script if needed.
The error() global function can be used to throw an error of the content that was put inside of it to the output. This can be very useful to throw an error in your script so that it prevents other code blocks below from running and bugging your game out.
The assert() global function can be used to throw an error just like the error() global function. But, it will only throw an error of the content that was put on the second argument when the first argument is false or nil. It is very useful just like error() and it is the shortened version of error(). It can be used to check if the condition of something is not nil or false to prevent bugs when running the code below it.