Destroying a Script or LocalScript with :Destroy() causes a lag spike.

I’ve discovered when making my game that destroying a script (via :Destroy()) will cause a lag spike. I can only observe this issue only in Roblox Studio, where a Script in ServerScriptService causes 1 lag spike, whereas a Script in Workspace causes 2 (I assume due to Replication). Its a very annoying bug for testing, You can replicate by making a script in Workspace/ServerScriptService and using the code below:

task.wait(5)
print("Lag Spikes Now")
script:Destroy()

A file to a game that will hopefully reproduce the error has been attached.
RuntimeErrorBug.rbxl (70.6 KB)

A recording of the problem is below:

Expected behavior

If everything was working correctly, destroying a Script wouldn’t cause a lag spike in Roblox Studio

6 Likes

Very annoying bug, Full support from me

2 Likes