-
-
Notifications
You must be signed in to change notification settings - Fork 2
Require Online Module
htt-py edited this page Sep 16, 2023
·
1 revision
Or Shortly ROM ARequire stands for Artificial Require
local RequireCache = {} -- Store required ModuleScripts for further use (ModuleScript persistance).
-- Fake Require func
local function ARequire(ModuleScript)
local Cached = RequireCache[ModuleScript]
if Cached then -- If module is already loaded, return it.
return Cached
end
local Source = ModuleScript.Source
local LoadedSource = loadstring(Source)
local fenv = getfenv(LoadedSource) -- Fake environment
fenv.script = ModuleScript -- Set script variable.
fenv.require = ARequire -- Overwrite require so it can require other modulescripts and so forth.
local Output = LoadedSource() -- Execute the module
RequireCache[ModuleScript] = Output -- Store module in cache for further use.
return Output -- Return the result to the executor
end
local function ARequireController(AssetId)
local ModuleScript = game:GetObjects("rbxassetid://" .. AssetId)[1]
return ARequire(ModuleScript)
end
return ARequireController
local FileName = "RequireOnlineModule"
local ARequire = loadstring(
game:HttpGet("https://raw.githubusercontent.com/luau/SomeHub/main/" .. FileName .. ".luau", true),
FileName
)()
local ModuleOutput = ARequire(2780820589) -- 2780820589 is AssetId for an online Roblox module that's been uploaded to the Creator Marketplace Library, ARequire works similar to require
print(ModuleOutput)
ALL DISCUSSIONS & QUESTIONS GO TO:
https://github.com/luau/SomeHub/discussions
Footer page
- text in red
+ text in green
! text in orange
# text in gray
@@ text in purple (and bold)@@
Test Siderbar