Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
0hsa 193
3 years ago
Edited 3 years ago

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

Log in to vote
2
Answered by 3 years ago
Edited 3 years ago

A ModuleScript will do!

Script:

require(workspace.ModuleScript)()

ModuleScript:

return function()
local env = getfenv(2) -- Script
env['message'] = "Hello There!"
setfenv(2,env)
end)
0
this. but you will need to store it in a module table, since this just defines a local variable. Speedmask 661 — 3y
0
Couldn't you use a BindableEvent? or do you mean change the env? MiAiHsIs1226 189 — 3y
0
I see your point. MiAiHsIs1226 189 — 3y
0
thanks, i don't understand getfenv() or setfenv() that well 0hsa 193 — 3y
Ad

Answer this question