> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# getcallbackvalue

> 读取 Instance 上 callback property 中保存的 Lua callback function。第一个参数必须是 Instance object，第二个参数必须是 string property name。instance reference 必须有效。property name 会通过 Roblox property metadata 解析，并且必须指向类型为 LUA_CALLBACK 的 property。如果 property descriptor 缺失、property 不是 LUA_CALLBACK、callback field offset 缺失、没有保存 callback、LiveLuaRef 缺失、callback 属于另一个 Lua global state，或引用的值不是 function，function 会返回 nil。当第一个 callback slot 没有 callback 时，它也会检查 async callback field fallback。function 不会更新 property。

<div className="real-function-page">
  ```lua theme={null}
  getcallbackvalue(instance: Instance, property: string): function | nil
  ```

  ## 别名

  * `getcallbackmember`

  ## 参数

  <ParamField path={"instance"} type={"Instance"} required>
    要检查 callback property 的 Instance object。Invalid Instance values 会抛出 argument error。
  </ParamField>

  <ParamField path={"property"} type={"string"} required>
    通过 Roblox property metadata 解析的 string property name。只有 LUA\_CALLBACK properties 可以返回 function。
  </ParamField>

  ## 返回值

  <ResponseField name={"callback"} type={"function | nil"}>
    callback property 保存的 Lua function，或 function 无法解析可读取 function 时返回 nil。
  </ResponseField>

  ## 示例

  读取 BindableFunction.OnInvoke 中保存的 callback function。

  ```lua theme={null}
  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
  ```
</div>
