Callbacks are write-only members of objects that are set to functions. You cannot invoke a callback directly — Roblox will internally trigger the callback function.

Notable Callbacks[edit]


To set a callback, you assign it to a function:

local bindableFunction ="BindableFunction")
bindableFunction.OnInvoke = function()
	return 1337

Callbacks are write-only, meaning you cannot get the value of a callback.

local bindableFunction ="BindableFunction")
--> OnInvoke is a callback member of BindableFunction; you can only set the callback value, get is not available

To invoke the callback, in this case you'll use BindableFunction:Invoke(). All of the arguments you pass to :Invoke() will be passed to the callback function, and then the return value from the callback function will be returned to the caller of :Invoke().

local bindableFunction ="BindableFunction")
bindableFunction.OnInvoke = function(n)
	return 2 * n
--> 84


The icon of callbacks (Callback icon.png) is similar to the icon of methods (Function Icon.png), but you can notice that there is a little difference.


Let's imagine a simple example: you want to make a BindableFunction and bind it to a function that receives two arguments, let's say, the Name of a part and its Size, and that creates a Part, puts it in the Workspace, and give it the Name and the Size passed to the function.

You would first create the BindableFunction:

local func ='BindableFunction', script.Parent)

And you would then connect it to your function, using the OnInvoke callback:

local func ='BindableFunction', script.Parent)
func.OnInvoke = function(name, size)
	local part ='Part')
	part.Name = name
	part.Size = size
	part.Parent = workspace

Now, you can just call the BindableFunction like this, and it will create the part:

BindableFunction:Invoke("Brick",, 50, 50))