is it possible to detect, when the script is deleting? like script.removing or something. i know i can use childremoved, but in my situation i have to detect when the script is being deleted inside that script and fire a function, but i dont know if that is possible at all
Unfortunately, no you can’t detect if script’s parent is changed from inside the script itself since setting parent or one of it’s ancestor’s parent to nil will stop script from running.
It is currently not possible to detect an object/script getting deleting using .Removed as it is not a valid RBXScriptSignal.
You can most likely just use Container.ChildRemoved() meanwhile.
May I ask what you plan to detect script removal for?
When a script is deleted it stops running immediately. This means that even if you could detect it from within the script it wont have time to do anything.
If you have a anti exploit that is getting deleted then that means you are using a local script. Keep your security on the server to prevent them from deleting it.
Well, you could just implement that function in another script and call it whenever that other script gets deleted (which you can tell using ChildRemoved connection)
as i have mentioned it wont work for my script i think or it will be difficult
You said that there was this function that you wanted to fire when the script gets deleted right?
If you could explain what that function is supposed to do I should be able to help.
ok im working on it already with some remote events and other stuff