Here’s a partial code of my event handler script. Most of the time when I exit out of studio, the process takes a lot of time to kill the running scripts. One of the running scripts affects the process and takes it longer to shut down. I found out that it was my event handler. I wasn’t sure why this happened because a couple months ago, I never seen this happened, but I wanted to point this out because it kept bugging me out.
-- idleTimeout: number (optional)
-- runService: game:GetService'RunService'
-- readyToReturn: boolean -> this variable is marked after one of the specified event handlers is done
-- wait: task.wait
local stWait = os.time()
repeat
wait()
if not runService:IsRunning() then break end
until
(idleTimeout and os.time()-stWait > idleTimeout) or readyToReturn
In the code, I added a break loop if the game isn’t running anymore, but somehow it still affects studio.
How do I fix this issue?