A DirectoryWatcher reports changes to files inside your workspace folder. Create one for a folder, connect to the events you care about, and your script is told whenever a file there is created, changed, deleted or renamed. The usual reason to want this is hot reload: edit a script in your editor and have the game pick it up without you running anything by hand.

Creating one

Events

Each event is a regular RBXScriptSignal, so Connect, Once and Wait all work as usual.

Properties

string
Read-only. The watched folder, relative to the workspace root, exactly as you passed it after normalisation.
boolean
Whether subfolders are watched too. Defaults to true. Writable, and a change takes effect immediately.

Paths

Every event reports a path relative to the workspace root, using forward slashes — the same form listfiles returns. That means you can feed it straight back into the filesystem functions:

Things worth knowing

  • Creating a file fires two events. Windows reports the file appearing and then its contents being written, so you get OnCreated followed by OnChanged. That is the operating system’s view, not a bug.
  • One save is one OnChanged. Editors often write a temp file and rename it, which would otherwise produce two or three events for a single save. Identical consecutive events are merged, so a save reports once.
  • Folders are not reported as changed just because a file inside them was touched.
  • Main VM only. A watcher cannot be created from inside an actor.
  • Watchers end with the session. Rejoining or teleporting clears them, as does Destroy.

Overflow

Windows delivers changes through a fixed buffer. If a burst is too large — say you delete a folder with thousands of files — individual notifications are lost. Athena caps its own queue as well, and when either limit is hit the whole burst collapses into a single OnOverflow. Treat it as “assume everything changed” and rescan.