Hello,
What I'm trying to do is, using a LocalScript, access a module through invoking a RemoteFunction which will return the contents of a ModuleScript in ServerStorage. To do this, here's what I setup...
Server (Script) [ServerScriptService]
local getClasses = Instance.new("RemoteFunction", game:GetService("ReplicatedStorage") getClasses.Name = "getClasses" getClasses.OnServerInvoke = function(p) local module = require(game.ReplicatedStorage:WaitForChild("Classes")) print(module) -- debugging return module end
Classes (ModuleScript) [ServerStorage]
local test = { ["Hello"] = function() print("hello world") end } return test
LocalScript [StarterPlayer > StarterPlayerScripts]
local rf = game.ReplicatedStorage:WaitForChild("getClasses") local class1 = rf:InvokeServer() print(class1, class1.Hello)
When you run the game using these, it will output table: 0x55bf868d9edefc4b nil
, while the expected output for me would be something like table: 0x00 function: 0x00
.
However, I don't understand why. I'm guessing it's something to do with networking.
The reason for me doing this is to have hidden pieces of code I want to hide from possible exploiters who constantly work towards leaking proprietary content. And since ROBLOX has disabled the feature to use the require()
on a off-sale model, I sincerely don't know what to do.
If anyone knows a fix for this, or possibly a better method, please let me know.
Thanks, - R455
It would seem you cannot pass a function into a remotefunction and likely not a remoteevent either but I haven't tried that. Also, since the module you're trying to return is inside of ReplicatedStorage, the client can still see it. And even if you moved it to somewhere the client wouldn't be able to see it, the client could still just invoke the function to get the returned module.. It's like fighting an uphill battle.