function triggerWriting(filepath)
if not fileExists(filepath) then
outputChatBox("file doesn't exist, about to create and write it!")
writeScriptsToDisk()
outputChatBox("starting to write...")
end
end
addEventHandler("onResourceStart",root,triggerWriting)
This is kinda wrong. The event onResourceStart doesn't provide any filepath, it only gives you the resource that was started.
Also, most times its better to use resourceRoot instead of root, when working with this event.