Recently, I found out that using Module scripts allows me to protect my work from clients till the script is complete. One problem occurred when trying to require a MainModule script from the client because it won't allow you to use the 'require()' on the client. After fiddling with RemoteEvents, I've finally ended up with a method to require a module from the client.
After solving that problem, I figured out that it will not work when running it in-game.
-- ServerScript 'A' (located in game.ServerScriptService) local events = game.ReplicatedStorage:FindFirstChild("Events") events.Animations.OnServerInvoke = function(player) local module = require(980963185) return module end
-- ModuleScript 'B' (located in game.ReplicatedStorage) local module = game.ReplicatedStorage.Events.Animations:InvokeServer() return module
-- LocalScript 'C' (located in game.StarterPack) local ninmodule = require(game.ReplicatedStorage.ModuleScript) ninmodule.Animations()
The result from running the script is as follows:
-- Players.Player1.Backpack.[S] Animations:4: attempt to call field 'Animations' (a nil value) -- Stack Begin -- Script 'Players.Player1.Backpack.[S] Animations', Line 4 -- Stack End
Is there any solution on how to call the module function from the client with Filtering-Enabled on?
Well, I'm not quite sure on what you're asking for. But this may help:
firstly, we need to be sure that the module is wired to a mirror, so that you can call it in scripts.
ex: THIS IS THE MODULE SCRIPT
local _m = {} --mirror right here function _m.printsomething() print("yo") end return _m
Now to link this module to a client, or a script would be done like this.
ex: THIS IS THE CLIENT, OR A SCRIPT THAT YOU ARE WIRING.
local module = require(game.ReplicatedStorage.ModuleScript) --now to simply call the function inside the module module.printsomething()
Simple as that.