Task Scheduler
Yield the running thread or spawn work onto a fresh Luau thread.
The External has no event system, so timing is explicit. wait yields the running thread; task.spawn starts a new one.
The pattern for anything continuous is a spawned thread with a loop and a wait, resolving its addresses each pass so a rejoin does not leave it reading a dead tree.
The standard loop
task.spawn(function()
while true do
local dm = get_datamodel()
if dm ~= 0 then
-- work
end
wait(0.05) -- ~20 passes a second
end
end)Pick the interval deliberately
Visual work wants to be fast; a whitelist check does not need to run twenty times a second. Every pass is memory reads out of another process, and they are not free.