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

# getscriptfromthread

> Returns the Script Instance associated with a Luau thread, or nil when no valid script reference is available.

<div className="real-function-page">
  ```lua theme={null}
  getscriptfromthread(thread: thread): Instance | nil
  ```

  ## Arguments

  <ParamField path={"thread"} type={"thread"} required>
    Luau thread whose associated Script Instance is returned.
  </ParamField>

  ## Retours

  <ResponseField name={"script"} type={"Instance | nil"}>
    Associated Script Instance when available; otherwise nil.
  </ResponseField>

  ## Exemple

  Read the Script Instance stored on a Luau thread, if one is attached.

  ```lua theme={null}
  local thread = coroutine.create(function()
  end)

  local scriptInstance = getscriptfromthread(thread)
  print(scriptInstance)
  ```
</div>
