---
title: "getscriptfromthread"
description: "Reads a thread's associated script."
---

```lua
getscriptfromthread(thread: thread): Instance?
```

---

## Aliases

None.

---

## Arguments

<ParamField body="thread" type="thread" required>
  The coroutine whose environment, script association, or stack is inspected.
</ParamField>

---

## Returns

<ResponseField name="script" type="Instance?">
  The associated script Instance, or nil when metadata is absent or expired.
</ResponseField>

Returns nil when thread script metadata is absent/expired.

**Related types:** [Scripts types & behavior](/reference/scripts/types).

---

## Example

```lua
print(getscriptfromthread(coroutine.running()))
```
