A script is a base-class instance that holds a section of the game. It is coded in the Lua language. Upon execution, scripts will normally run automatically and has access to the server events and properties. Scripts have the ability to run inside the Workspace, or ServerScriptService.
Scripts are a fundamental element to the Studio and it is at the core of game creations. All games run through multiple scripts that are simultaneously threaded, enabling developers to run other objects over the top of scripts.
Features of a script
A script has an infinite amount of lines that it can hold at a given time. Each line's indentation is pre-determined by its previous lines. For example if the previous line consists of a function, RBX.lua will be able to indent the next line, so that the formatting of such scripts would appear readable upon reboot. In turn, the script will add an "end" statement in the next line.
Properties of a script
- Disabled determines whether or not the script will run.
- LinkedSource is used to store a URL that points to an online script source.
- CurrentEditor returns the player who is currently editing the script.
Types of scripts
As the name implies, server scripts deal with server-sided events, such as the leaderboard. Server scripts can only access server-sided events and properties. That is, the server script cannot access the player's GUI, as well as the client itself. However, they may be able to communicate with local scripts in order to manipulate the player if necessary. This is done through remote events and remote functions. Server scripts can only access the Workspace and the ServerScriptService.
- Main article: Class:LocalScript
Local scripts works on the backend data. That is, local scripts have the ability to manipulate the player, as well as access the client events and properties. As such, local scripts are mainly used when dealing with the player property, such as the Camera. However, they may be able to communicate with server scripts in order to access the server events through the communication of remote events and remote functions. Local scripts can only access the player's gui, as well as the backpack.
- Main article: Class:ModuleScript
- Newbie's Guide to Scripting
- Beginners Guide to Scripting
- Intermediate Guide to Scripting
- TUTORIAL: The Disappearing Brick