Instances

getcallbackvalue

Reads a callback property from an instance when the callback can be inspected.

Syntax

getcallbackvalue(instance: Instance, property: string): function | nil
Aliases getcallbackmember

Arguments

NameTypeDescription
instanceInstanceRoblox instance to inspect or update.
propertystringProperty name to read or change.

Returns

NameTypeDescription
callbackfunction | nilCallback function, or nil when the callback cannot be read.

Description

Reads a callback property from an instance when the callback can be inspected.

Call it with 2 parameter(s): instance, property. The argument table explains which values are required and which ones only refine the behavior.

It returns callback (function | nil). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Read the callback assigned to a callback property such as BindableFunction.OnInvoke.

local bindable = Instance.new("BindableFunction")
bindable.OnInvoke = function(value)
    return value * 2
end

local callback = getcallbackvalue(bindable, "OnInvoke")
if callback then
    print(callback(21))
end