Beginners Scripting Guide (BETA)
  • Getting Started
  • Basic Data Types
  • Variables
  • Basic global functions
  • Number Arithmetic & Compounds Assignment
  • If statement
  • Function
  • Table & Dictionary
  • Loops
  • Creating An Object
  • Understanding Client & Server
  • RemoteEvent
  • Unfinished & In-progress
    • Methods
    • RemoteFunction
    • Basic libraries
    • Basic Services
    • Basic of Vector3 and CFrame
    • Basic built-in events
Powered by GitBook
On this page
  • PRINT GLOBAL FUNCTION
  • WARN GLOBAL FUNCTION
  • ERROR GLOBAL FUNCTION
  • ASSERT GLOBAL FUNCTION

Basic global functions

✏ Beginners Scripting Guide ✏

PreviousVariablesNextNumber Arithmetic & Compounds Assignment

Last updated 11 months ago

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.

PRINT GLOBAL FUNCTION

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.

WARN GLOBAL FUNCTION

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.

ERROR GLOBAL FUNCTION

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.

ASSERT GLOBAL FUNCTION

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.

https://create.roblox.com/docs/reference/engine/globals/LuaGlobals#print
https://create.roblox.com/docs/reference/engine/globals/LuaGlobals#error
https://create.roblox.com/docs/reference/engine/globals/RobloxGlobals#warn
https://create.roblox.com/docs/reference/engine/globals/LuaGlobals#assert