> For the complete documentation index, see [llms.txt](https://kaizo-1.gitbook.io/kaizo-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kaizo-1.gitbook.io/kaizo-docs/lua-engine/getting-started/setup-and-creating-scripts.md).

# Setup and creating scripts

## Where scripts live

Scripts go here:

```
~/.config/linux-rbx-external/scripts/
```

Only files ending in `.lua` are loaded.

You can open that folder from the menu with Open folder.

## Turn scripting on

1. Open the Kaizo menu with Insert or Home.
2. Go to Scripts.
3. Turn on Enable scripts.
4. Optional: turn on Autoload so scripts start when Kaizo starts.

If Enable scripts is off, scripts show as Paused even if Run is on.

## Make a new script

1. Open the scripts folder.
2. Create a file like `my_script.lua`.
3. Put Lua code in it.
4. In the menu press Refresh if you do not see it.
5. Press Run on that script.

After you edit the file, press Reload.

## Add example scripts

In Scripts you can use Add example.

* Hello overlay
* UI demo

You can also copy files from the repo folder `examples/scripts/` into your scripts folder.

## Minimal script

```lua
function on_load()
    log.info("my script loaded")
    toast.push("my script loaded")
end

function on_draw(draw)
    draw.text(40, 100, 0xFFFFFFFF, "hello from lua")
end

function on_unload()
    log.info("my script unloaded")
end
```

## Run controls

* Run turns the script on
* Reload stops it, loads the file again, then starts it
* Delete removes the file

## Memory writes

Some sdk and unsafe\_memory calls write to the game.

Those only work if Disable memory writes is off in Misc.

## Limits

* Each script has its own Lua state
* Heap cap is about 16 MiB
* Hooks have time budgets. If a hook is too slow, the script gets disabled

## Next

* [Lifecycle hooks](broken://pages/Cr2LqX0pQBGgF890XGxT)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://kaizo-1.gitbook.io/kaizo-docs/lua-engine/getting-started/setup-and-creating-scripts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
