This should be a pretty simple question to those who know, but i ask this because i can return their individual environments with getfenv. So, is LoadLibrary like saying require?
Comparison:
Module:
local t = {} a = 1 b = 2 t.test = function() end return t
Script:
-- This script is inside the module script local env = getfenv(require(script.Parent).test) table.foreach(env,print) -- Output -- -- a 1 -- b 2 -- script ModuleScript
And the same effect happens with LoadLibrary:
table.foreach(getfenv(LoadLibrary'RbxUtility'.Help),print) -- Output -- -- Encode function -- Decode function -- Null function
So, that's pretty much it. It just seems to me that LoadLibrary is like another way of saying require, except it's parameter is limited to the string value of all it's library names.
Long ago in a ROBLOX without require
, there was LoadLibrary
.
This was a global function that allowed us to import a few whitelisted libraries that ROBLOX provided. Almost all of their functions have by now been fully replaced with official implementations.
The end.