The method SetTimeout of the ScriptContext service no longer works, scripts that never yield at all no longer get halted when setting a valid timeout (say 5).
It broke somewhere in the last few months and I thought it’d just not work in certain more complex circumstances, but now I tried it out with a basic infinite Lua-only while-loop (while true do ; end) without any API calls where it never aborts the execution too (tested through command bar and a serverscript in Play Solo).
It’s an absolute pain to debug code that never yields now, especially since you have to keep rebooting Studio… (and the stack trace was a great utility for debugging too!)
It does detect it now appearantly, some popup shows up after like 5 seconds, but it seems to not do anything and never terminates the script(?). Something changed though, since this popup wasn’t there before.
That new dialog is meant to let you stop scripts just like SetTimeout did, but I can’t actually click anything in the dialog because studio freezes up, so I’ve found it useless.
SetTimeout still works for me, though. I use a plugin to set it automatically. I think that near the start of the game the timeout is reset or turned off, so I set it in a loop.
Here is the only script in the plugin:
repeat
game:GetService("ScriptContext"):SetTimeout(20)
until not wait(5)
You’re right there! When I SetTimeoutafter starting the game through e.g. the command bar, it still works properly, but when doing it before running the game, it (sadly) fails. This did work properly some time ago though (SetTimeout through command bar -> Play Solo -> Timeout it still adhered to).
I’m pretty sure you only have to set it once per game instance.
That means, opening a place, play solo, start server and start player. (anytime doing print(_G) in the commandline gives something different)
I only set it once from the StarterScript (OverrideCoreScripts, cuz also other hax) and it works fine for me…
EDIT: After some testing: (unrelated to Corecii)
Commandline still crashes, doesn’t use the popup nor SetTimeout
Play Solo spawns the “(Not Responding)” popup, which when closed crashes studio. Actually after running it several times, it only crashed that first time, idk why Scrap that: it crashes whenever it feels like it
Everything else (like Run & Start Server) doesn’t make use of the popup crap.
Using SetTimeout works for those, though
More details about the popup:
It activates when a coroutine doesn’t yield for 10s
It might be stuck on “Not Responding”, basicly being useless and crashing studio
While the popup is open, scripts are frozen, they resume after the popup is closed
Clicking Break will start the debugger in the script at the place the infinite loop is. (well, somewhere there, it’s like “Script took too long, pause and debug where we ended up”)
Clicking Kill Script will make the infinite loop error “Script execution stopped by user”.
Other threads (coroutines in the task scheduler) in the same script still run.
Other scripts aren’t affected at all.
A big thing is that the popup overwrites SetTimeout for regular (local)scripts.
Regular scripts aren’t affected by SetTimeout at all, only by the popup.
This might be a good thing, otherwise all scripts would timeout. (because the popup takes 10s, if your timeout is 10s, everything times out after it is closed)
Corescript stuff (including the StarterScript) are still affected by it ,so eh… Result: During a global timeout, everything is timed out except regular scripts.
Since corescripts don’t use while wait() loops (I think) this actually isn’t a problem. Note: Since the popup doesn’t work in Edit / Start Server, it doesn’t overwrite SetTimeout there.
(At least, that’s what I found out while I played around with it)