Fires when a file’s contents change.

Parameters

string
required
The file whose contents changed, relative to the workspace root.

Behavior

  • One save, one event. Editors commonly write a temporary file and rename it over the original, which would report two or three times. Identical consecutive events are merged, so a single save fires once.
  • Folders are not reported. Touching a file inside a folder does not report the folder as changed.
  • This is the hot-reload event. Pair it with readfile and loadstring.

Example

  • OnCreated: fires first for a brand new file.
  • readfile: read the path you were given.