I would use a pcall on the code inside of the script you are watching (to differentiate between it erroring or running all the way through), then when it finishes update a value or something somewhere, then detect the .Changed event on that value from a different script.
First off, you are just repeating what I said which was to use a pcall. Secondly, your code isn’t even correct. You would check Success & Failed outside of the pcall, not inside of it.
--// Module
for i = 1, 10 do
print("running: " .. tostring(i))
task.wait(0.1)
end
return nil
--// Script
print("script started")
local success = pcall(function()
require(script.Module)
end)
if success then
print("script finished")
else
print("script errored")
end
These all seems to be very hackish ways to seeing if a script finished. In my case the script must not be a module or function and instead just a script. If this helps at all, I’m using local scripts to execute code.