Roblox Game Development/Game code

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Scripts, which can manipulate game objects, are contained in objects that are part of the game hierarchy. There are four kinds of scripts: server scripts, local scripts, core scripts and starter scripts. They respectively correspond to the classes of the names "Script", "LocalScript", "CoreScript" and "StarterScript". Server scripts are scripts that run on the server while local scripts run on a player's client (the client in question depends on the local script's location in the game hierarchy). Core scripts and starter scripts cannot be used by game developers and are internal to ROBLOX.

You can create a script by using the basic objects panel in the studio. Find the class name of the script you want and double-click on it to insert the script. Scripts will not run everywhere; while there are many places where they can run, most of the time, you will want to put them in the workspace service. Once the script is inserted, it can be edited by double-clicking on it in the explorer panel. This will open a new tab with a script editor, where code can be put. It can then be executed by closing the script editor and running the game with the green run arrow located in the testing toolbar.