ReferenceReflection

getcallbackthread

Returns the thread that assigned a callback property.

Syntax

getcallbackthread(object: Instance, property: string) -> thread?

Parameters

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

Returns

TypeDescription
thread?The thread that installed the callback, or nil when none is set.

Description

Callback properties such as BindableFunction.OnInvoke hold one function each. This returns the thread whose code assigned it, which you can pass to getscriptfromthread or gettenv to see which script owns the callback. Read the function itself with getcallbackvalue.

Example

local bindable = Instance.new("BindableFunction")
bindable.OnInvoke = function() return true end
print(getcallbackthread(bindable, "OnInvoke") == coroutine.running())

Notes

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