> ## 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.

# setscriptable

> Luu scriptable override cho Roblox property trong scriptable override cache va tra ve previous scriptable state. Doi so dau tien phai la Instance object, doi so thu hai phai la string property name, va doi so thu ba phai la boolean. Neu da co cache entry cho cung instance reference va property name, cached scriptable value duoc thay the va cached value cu duoc tra ve. Khi cache miss, property name duoc resolve qua Roblox property metadata va Instance class descriptor. Neu khong co descriptor, hoac field duoc resolve bi thieu hoac khong phai property entry, function tra ve nil. Khi tim thay property entry, function doc scriptable state, luu boolean duoc yeu cau cung property reference vao scriptable override cache, roi tra ve previous scriptable state value. GameIndexHook va GameNewIndexHook sau do dung cache nay bang cach tam thoi dat property field scriptable flag cho mot indexed read hoac write duy nhat, roi khoi phuc previous field flag.

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

  ## Đối số

  <ParamField path={"instance"} type={"Instance"} required>
    Instance object duoc dung nhu mot phan cua scriptable override cache key.
  </ParamField>

  <ParamField path={"property"} type={"string"} required>
    Property name duoc resolve qua Roblox property metadata va Instance class descriptor khi cache miss.
  </ParamField>

  <ParamField path={"value"} type={"boolean"} required>
    Scriptable override value de luu vao scriptable override cache.
  </ParamField>

  ## Giá trị trả về

  <ResponseField name={"previousState"} type={"boolean | nil"}>
    Previous cached scriptable value, previous scriptable state value, hoac nil khi property khong the resolve thanh property entry.
  </ResponseField>

  ## Ví dụ

  Temporarily change whether a property is scriptable, then restore the previous state when available.

  ```lua theme={null}
  local previous = setscriptable(workspace, "Name", true)
  print(previous)

  if previous ~= nil then
      setscriptable(workspace, "Name", previous)
  end
  ```
</div>
