getcallbackvalue
Gets the function assigned to a callback property.
Syntax
getcallbackvalue(instance: Instance, property: string) -> function?Parameters
| Parameter | Type | Description |
|---|---|---|
instance | Instance | The instance |
property | string | The callback property name |
Returns
| Type | Description |
|---|---|
function? | The callback function, or nil if not set |
Description
getcallbackvalue retrieves the function assigned to a callback property like OnInvoke or OnClientEvent.
Example
-- Create a BindableFunction
local bindable = Instance.new("BindableFunction")
bindable.OnInvoke = function(arg)
return arg * 2
end
-- Get the callback
local callback = getcallbackvalue(bindable, "OnInvoke")
print(callback(5)) -- 10Inspecting Remote Callbacks
-- Find RemoteFunction callbacks
for _, obj in ipairs(game:GetDescendants()) do
if obj:IsA("RemoteFunction") then
local callback = getcallbackvalue(obj, "OnClientInvoke")
if callback then
print("Found callback on:", obj:GetFullName())
end
end
endNotes
- Common callback properties:
OnInvoke,OnClientInvoke,OnServerInvoke - Returns nil if no callback is set