Method

From Legacy Roblox Wiki
Revision as of 14:26, 23 December 2010 by >TaslemGuy (Created the page. Please improve, might not be to Wiki Standard.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Introduction

Methods are functions which belong to a particular object. Although standard Lua doesn't have them, they're a major focus of Roblox Lua. Methods act like a function stored within an object. The method itself is accessed in the same way a Function in a Table is accessed. However, a special property of methods changes how they are called.

These two codes call the same function (a) with the same parameters (b).

 
b.a(b) 
b:a() 

The second is more brief and concise. Methods can increase typing speed, because there is less need to retype variable names. Methods may or may not return data.

Examples

All instances (possibly excluding) some core services, have the remove method, along with the clone method. Sounds have the Play method and the Stop method.