Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to getfenv() of another script without calling an event from it?

i made an import function on roblox which sets a variable in an environment but currently you have to pass getfenv() through the function for it to work, which kind of ruins the thing i was going for. what are other things i could try?

1 answer

✓ Accepted answer

A ModuleScript will do!

Script:

require(workspace.ModuleScript)()

ModuleScript:

return function()
local env = getfenv(2) -- Script
env['message'] = "Hello There!"
setfenv(2,env)
end)

4 comments

0

this. but you will need to store it in a module table, since this just defines a local variable.

0

Couldn't you use a BindableEvent? or do you mean change the env?

0

I see your point.

0

thanks, i don't understand getfenv() or setfenv() that well

This discussion is preserved as it was. New answers, comments, and votes are closed.