ReferenceMiscellaneous

DirectoryWatcher.new

Reports changes to files under a workspace folder.

Syntax

DirectoryWatcher.new(path: string) -> DirectoryWatcher

Also available as

DirectoryWatcher

Parameters

ParameterTypeDescription
pathstringWorkspace folder to watch.

Returns

TypeDescription
DirectoryWatcherAn object with an OnChanged signal and :Destroy().

Description

The folder is checked every 0.1 seconds. OnChanged fires with the path of each file that was written, added or removed since the last check. After :Destroy() the signal no longer fires. Changes of less than one check interval can merge.

Example

makefolder("watched")
local watcher = DirectoryWatcher.new("watched")
watcher.OnChanged:Connect(print)
writefile("watched/a.txt", "hello")
task.wait(0.5)
watcher:Destroy()
delfolder("watched")

These are Game executor contracts. Check build requirements and session lifetimes before using them.