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

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

## Syntax

```lua theme={null}
getscriptfromthread(thread: thread): Instance | nil
```

## Arguments

| Name     | Type     | Required | Description                                               |
| -------- | -------- | -------- | --------------------------------------------------------- |
| `thread` | `thread` | Yes      | Luau thread whose associated Script Instance is returned. |

## Returns

| Name     | Type              | Description                                               |
| -------- | ----------------- | --------------------------------------------------------- |
| `script` | `Instance \| nil` | Associated Script Instance when available; otherwise nil. |

## Example

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)
```
