Ability to detect when a script has opened

As a developer creating plugins, I feel that it would be extremely useful to be able to listen to an event which fires when a script is opened.

Here is an example of implementation:

workspace.YourScriptHere.Opened:connect(function()
	print("This script was opened")
end)

This event would also only be avaliable in the command bar and plugins.

There are a few use cases, for instance, I am making an unofficial TeamCode plugin and it listens for a script to be opened for other logic to occur. Other use cases I can think of is adding module requires to the top of scripts automatically sort of like how some other coding languages do with their classes, or maybe another use case being changing script colors depending on which script you are in. These scenarios are mostly plugin based and are not the only use cases.

2 Likes

Would help if you provided a use case.

Also, this sounds better as an event that fires for ALL scripts, not just Script.Opened.

1 Like

Added some use cases.

So do you mean implementation such as:

game.ScriptOpened:connect(function(Script)
   print(Script.Name.." was opened")
end)

Otherwise I don’t quite understand you here.

Yes, I do. However, you shouldn’t suggest APIs. The engineers don’t care what you think the API should be, they just want to hear the feature suggestion.

2 Likes