Script Not Running In CoreGui

I’ve started working with plugins, and I’m inserting a UI into CoreGui using :Clone(). Yet the script doesn’t run? Is there anyway I could have it run when the UI gets cloned? Events don’t work either.

I don’t believe you can clone scripts in CoreGui.

CoreGui only runs CoreScripts so you cannot run plugin code from there.
From what I know, the only time a plugin can run scripts are when:

  • Scripts under the Plugin instance when the DataModel is loaded.
  • Scripts under a StandalonePluginScripts instance that is parented to the Plugin instance when Studio is opened (although it’s functional, the API for this is currently unfinished).
  • Scripts under TestService when TestService:Run() is called.
  • ModuleScripts called with require()
  • Code strings ran via loadstring()
  • A BaseScript such as a Script or LocalScript injected into the DataModel and parented under a container instance where it can be ran, and running a simulation via RunService:Run() or having the user press the ‘Play’ button.

Using any of these should work, just try to avoid user-unfriendly options such as injection & running the place file.

2 Likes