Is there any way to access the global environment through a plugin's environment?

I’m aware that plugins have their own separate environments but I’m trying to access the global/game environment to set a global variable accessible to user-created scripts. Because plugins run in their own environment setting _G.VariableName will not be accessible to regular scripts. Is there any way to overcome this to create a user-friendly endpoint?

1 Like

Is there a specific need/use for this? If you can let us know, it can help us find a solution better

My plugin generates a custom 2D animation object. To play this animation a module has to be externally downloaded and used. I’ve had a lot of people find this to be extremely annoying and confusing. I want to simplify the process by defining a global function such as: _G.RoUI2.PlayAnimation().

So your plugin will automatically download it for them, and to play an animation, they type that command in the command bar?

Because if it is in scripts, plugins aren’t available ingame, only in studio.

What you could do is have your plugin automatically install this module for them

I’m aware that’s the problem. I’m trying to find a way to exit out of the plugin environment and into the game environment.

My plugin already has a download button in the toolbar that extracts the module source from GitHub and places it into ReplicatedStorage. Still people find this confusing since the documentation isn’t obvious.

1 Like

Ok, so what exactly is the problem?
You say you want to enter the game’s environment, just use game and workspace. They work within a plugin

Or are you trying to access the environment of a specific script?

No offense but I don’t think you’re advanced enough to help me here. I’m talking about a function environment. Plugins run on a higher environment than the game. I’m trying to exit out of the plugin environment and access the game’s environment (what is replicated to every script).

Ah, sorry the global script environment.

But you said you wanted to define a function in _G right?
But if you use it in scripts, it won’t work because plugins are studio only (and you mentioned this)
So I’m confused. Do you want this function to be accessible within scripts? Is it within the Studio only?

You say you want to “exit the environment” but I don’t think thats possible

Yeah exactly that’s why I was asking if there was some solution to this cause I didn’t think so either. It’s unfortunate cause it’s really limiting. I wanted the function to be accessible within scripts without having to download an external module.

1 Like