Fandom

ROBLOX Wikia

Script

4,753pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Script example

Looking at the source of a script through a built in text-editor from Roblox Studio

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.

NewScriptIcon

New ROBLOX Script Icon

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.
  • Archivable determines whether the object will be saved when the object is saved to a file.
  • ClassName returns the unique name of this type of instance.
  • Name returns the non-unique identifier for the object.
  • Parent returns the hierarchical parent of the object.

Functions of a script

  • ClearAllChildren() removes all descendants of such object.
  • Clone() returns a copy of the object, including all of its descendants.
  • Destroy() sets the parent property to nil, locks the parent property, disconnects all of the descendants, and calls the Destroy() function on all of its descendants.
  • FindFirstChild(name, recursive = false) returns the first child with the given name, or nil if no such child exists. If recursive is set to true, recursively descends the hierarchy while searching rather than only searching the immediate object.
  • GetChildren() returns an array of the object's children.
  • GetFullName() returns a string which shows the object's ancestry chain.
  • IsA(className) returns true if the object is an instance of the given class, or if the object's class inherits from the given class.
  • IsAncestorOf() returns true if the object is an ancestor of the given descendant.
  • IsDescendantOf() returns true if the object is a descendant of the given ancestor.
  • WaitForChild(childName, timeOut) yields the current thread until a child with the given name is found, then returns the child. If the timeOut parameter is specified, this function will drop out and return nil if the timeOut is exceeded.

Events of a script

  • AncestryChanged fires when the parent property of the object or one of the ancestors is changed.
  • Changed fires when the property of the object is changed.
  • ChildAdded fires when a child is added to the object.
  • ChildRemoved fires when a child is removed from the object.
  • DescendantAdded fires when a descendant is added to the object.
  • DescendantRemoved fires when a descendant is removed from the object.

Types of scripts

Server 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.

Local scripts

Main article: Local script

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.

Module scripts

Main article: Module script

Further reading

See also

Start a Discussion Discussions about Script

  • Scripting

    • '''How many scripters are in this wiki? (begginer's and nonbegginers.)'''
  • Scripting Lava Jumps

    5 messages
    • right click on what you are puting it in. click insert object. click script. click on the script you inserted. copy and paste the script.
    • this is the first time i found real script. I always find scripts but there fack!

Also on Fandom

Random Wiki