UPDATE This update is live as of February 3rd, 2020.
UPDATE This has been postponed once more to February 3rd.
UPDATE This has been postponed to January 6th; the post has been updated with the new timeline.
What’s going on?
LoadLibrary
is a legacy mechanism that we previously used to provide access to Roblox-maintained Lua code. However, we haven’t updated the list of libraries or the libraries themselves in ages. There are three libraries: RbxGui
, RbxStamper
and RbxUtility
; the first two are almost never used, the last one is occasionally used by some games for helpers like RbxUtility.Create
.
LoadLibrary has been challenging for us to support due to mechanics of how Lua library loading works on the client. Because of this, we have inadvertently broken this mechanism a few times, and it prevents development of some internal changes.
Additionally, Studio has been warning about LoadLibrary
deprecation for several years now (via Script Analysis widget).
Given all of the above - it’s a rarely used mechanism that is expensive for us to maintain that has been deprecated for a while and easy to stop using - we have decided to remove this function entirely.
Removal timeline
Because LoadLibrary
has been deprecated for years we feel that we can move relatively quickly, but we want to make the transition away from this functionality as painless as possible. So the removal is going to come in three stages:
- November 13th 2019: any use of
LoadLibrary
will produce a warning in the output window. The function will continue working as before. - February 3rd 2020: any use of
LoadLibrary
will start failing.
This schedule will give a bit more time for the community to transition plugins and server-side code away from LoadLibrary
.
How do I know if my code is affected?
The easiest way to tell is to search for LoadLibrary
(case sensitive) in all your scripts. Note that Script Analysis tab will contain a warning for every use of LoadLibrary
- we recommend keeping your code clean of deprecation warnings in particular, as functions are deprecated for a reason.
After November 13th you will be able to run your game in Studio or live and check if output contains any warnings, but we recommend proactively removing LoadLibrary
instead of waiting - this will make sure you don’t use it even in rarely executed parts of your code
I use LoadLibrary, what do I replace it with?
We recognize that you don’t really want to spend a lot of time cleaning up uses of LoadLibrary. Usually the use of LoadLibrary
is just for RbxUtility.Create
which is a simple enough function to replicate, but some of you may be using RbxStamper
or RbxGui
. The good news is that it’s easy to replace LoadLibrary
with the use of ModuleScript
s and require
. Here’s how to do this:
- Download the attached file that contains 3 ModuleScripts in a Folder:
LoadLibrary.rbxmx (249.0 KB)
-
Insert it into your game into ReplicatedStorage by right clicking ReplicatedStorage, choosing “Insert from File…” and locating the file you downloaded.
-
In your script code, replace
LoadLibrary
calls withrequire
as follows:
local RbxUtility = require(game:GetService("ReplicatedStorage"):
WaitForChild("LoadLibrary"):WaitForChild("RbxUtility"))
-- call RbxUtility.Create as usual
Of course you are free to put the libraries into any other location in your game’s hierarchy, and you can remove RbxStamper / RbxGui if you only need RbxUtility.
That’s it! That’s all it takes.
Please be proactive about changing this so that the actual removal of this functionality doesn’t take you or your game by surprise.
Fun fact: this post contains 20 mentions of the word LoadLibrary.