Hello! So I’m making 1 plugin and I need to detect when the script is being closed. There no any event that fires when script is closed at all (i guess since I searched on hub). Yes there is a ScriptChangeService
that could help me but I cant use it without permission 5 or something. CurrentEditor
property changes only when Team work is enabled. So basically.
Is there any way to detect when script being closed?
Not sure but maybe u can use a for loop to see the existence of a specific script?
Are you looking to achieve this in a development environment or a production environment?
I don’t know really what you mean but if I did then my answer would be development environment. Overall I decided to go with another way instead of detecting when script being closed.
I don’t think it would help.
30 symbols
You can use the ‘Destroying’ event of an instance to detect when it is destroyed and respond accordingly.
local Script = script
local function OnDestroying() --This callback function cannot contain any yielding code (as the script will have been destroyed before it gets executed).
print("Hello world!") --Hello world.
task.wait(1)
print("Test?") --Doesn't print.
end
Script.Destroying:Connect(OnDestroying)
Script:Destroy()
That’s detects when script is being destroyed. Not when its being closed.
There is no way to detect it. Thanks for trying to help.
https://developer.roblox.com/en-us/api-reference/property/StudioService/ActiveScript
I understand what you mean now, this functionality does exist in some form.
Thanks! Didn’t thought StudioService had this!