Open kalrnlo opened 1 month ago
I will note I did a quick test of changing the global name to something else, and it didn't error so this weirdly seems to be specific to setting the game global?
the issue that youre having is not exactly from those 2 lines of code.
the issue is that in another script (which is being required) youre either trying to get or set a property of game
which causes lune to call this function right here https://github.com/lune-org/lune/blob/main/crates/lune-roblox/src/instance/registry.rs#L42 which needs to borrow the app container if the function is called for the first time
[!NOTE] not all properties will cause lune to call this function, so something as simple as
game.Name
will not call it
the cause of the issue: when a script is in the process of being required, the app data container is borrowed by that require process, so if you use a library that needs the app container, you will get the error.
the workaround is to somehow call https://github.com/lune-org/lune/blob/main/crates/lune-roblox/src/instance/registry.rs#L42 in your very first script that isnt in the process of being required
the easiest way to do that, is to get/set a property that doesnt exist at all which causes lune to check all alternatives (one of them being the function that we need to call)
local roblox = require("@lune/roblox")
game = roblox.Instance.new("DataModel")
pcall(function()
return game.Shutdown
end)
-- now you can continue
the following code errors with