Roblox Wiki
Roblox Wiki
Advertisement
Roblox Wiki

A method is a function member of a class that can be called on an instance, representing a method in object-oriented programming. Methods are expected to be called using a colon (:) instead of a period (.), although methods can be called using the period with the first parameter expected as an instance.

Usage[]

This code will instantiate Part light iconPart dark iconPart and calls its method IsA, which is an Instance method, passing the class name BasePart as a string. Then, it will print the result as true because its class Part is a subclass of BasePart.

local part = Instance.new("Part")
print(part:IsA("BasePart")) -- true

There are a few cases where a dot is used instead, for example:

local destroy = game.Destroy -- this function can be used instead of calling the Destroy method on an instance, since it accepts one of any instance.
destroy(workspace.Part) -- destroys a part in the workspace.
Advertisement