Wiki Page, Programming School: Lesson 1: Objects and Functions

Wiki Page
2017-02-01T07:49:14-07:00

Objects will be covered in this module. An object would be called like this: 'workspace.Part'. Simple. It shows Lua the whole path to reach it in your game. If it's under another object, you would just put the name of the parent object behind it like this: 'workspace.Thing1.Part'. Another method would be to use 'Parent'. If it's in another object, you can put 'script.Parent.' then the object/attribute you want to affect. 'script' will always refer to the script you are currently in, and is needed before a Parent.

Parent can be called as many times as you want in one go, assuming there's that many objects to go through. If you have a Part nested in another Part in the workspace, and you don't want to type it all out (or your Part may be moved at any time and is not definite), you could call 'script.Parent.Part' instead of 'workspace.Part.Part', and it's more definitive if you have multiple things with the same name, like if you have two Parts in one level.

Using a function on an object is easy. Just append a colon (':') to the end of the object path. Say, if you want to remove the Part a script is in, just run 'script.Parent:Destroy()'.

The ROBLOX Wiki is very helpful at finding what functions can be preformed on what objects, so here's a link to all functions that can be run on a Part: http://wiki.roblox.com/index.php?title=API:Class/Part#FunctionsmemberhiddenFunctions_.5Btoggle.5D