Hi,
I have problem, that i am moving code to module script and script variable is shortcut for the modal script, so almost everything isnt working, so how can i get shortcut on the script, i am executing it from?
Edit:
So if i have some script
local m = require(game.ServerScriptService.modul)
m:returnscript()
and modul
local m
function m:returnscript()
...........
end
return m
how can i make, that the function returnscript will give me the first script and not the module?
local m
function m:returnscript()
-- This is function environment 0, relative to the getfenv call --
return getfenv(2).script
end
-- This is function environment 1, relative to the getfenv call --
return m
...
-- Your non-module script: --
-- This is function environment 2, relative to the getfenv call shown in the module script code --
local ms = require(game.ServerScriptService.modul)
ms:returnscript() -- Returns the script object running this code
Remember that “script” is a local variable, just like “ms” and “m”. “script” is just a local variable that is localized to the scope of the entire script implicitly.