ReferenceInstances

getcallbackvalue

Reads a callback property, which scripts can assign but not read.

Syntax

getcallbackvalue(object: Instance, property: string) -> function?

Also available as

getcallbackfunctiongetcallbackmemberget_callback_functionget_callback_memberget_callback_value

Parameters

ParameterTypeDescription
objectInstanceThe Instance whose callback property to read.
propertystringThe callback's name, such as "OnInvoke", "OnClientInvoke" or "OnServerInvoke".

Returns

TypeDescription
function?The function currently assigned, or nil when none is set. A member that is not a callback raises an error.

Description

Callbacks such as BindableFunction.OnInvoke and RemoteFunction.OnClientInvoke are write-only from Luau. This returns the function a script assigned, so you can call it, inspect it or wrap it with setcallbackvalue.

Example

local remote = game.ReplicatedStorage.GetData
local handler = getcallbackvalue(remote, "OnClientInvoke")
if handler then
    print(handler("test"))
end

Notes

These are Game executor contracts. Check build requirements and session lifetimes before using them.