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.
To set a callback, you assign it to a function:
Callbacks are write-only, meaning you cannot get the value of a callback.
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().
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 = Instance.new('BindableFunction', script.Parent)
And you would then connect it to your function, using the OnInvoke callback:
local func = Instance.new('BindableFunction', script.Parent) func.OnInvoke = function(name, size) local part = Instance.new('Part') part.Name = name part.Size = size part.Parent = workspace end
Now, you can just call the BindableFunction like this, and it will create the part:
BindableFunction:Invoke("Brick", Vector3.new(50, 50, 50))