Module Script on Server Storage Access by Client

Is there a way to access module script on server storage by using local script?

local module = require(ServerStorage.ModuleScript)

This will start the module script. You can run functions inside it remotely using

module.Function()

But I thought Client can’t get Server-thing?

Because I’m talking about from Server Storage, not Replicated Storage

Sadly no, the only possible way is anything that both Client & Server can reach!

You can try the use of RemoteFunctions, make a Script that returns the access of ModuleScript to the LocalScript called it.

Can you give me reference how to return the access?

1 Like

Like return require(module) ? Char eeeeeeeeeeeee

Assume this hierarchy as the example, the access can work like this:
image

LOCAL SCRIPT


-- because this LocalScript is in ReplicatedFirst, you must wait for it to load
local remoteFunction = game:GetService('ReplicatedStorage'):WaitForChild('RemoteFunction')
local module = remoteFunction:InvokeServer()

print(module.Message)

SERVER SCRIPT (Retriever)

local function access(player)
	local module = require(game:GetService('ServerStorage').ModuleScript)
	return module
end

game:GetService('ReplicatedStorage').RemoteFunction.OnServerInvoke=access

MODULE SCRIPT

local module = {}

module.Message = 'Hello world!'

return module

Tested output:
image

I don’t recommend you to put ModuleScripts in ServerStorage if you will have to use it frequently with LocalScripts (unless required). But this should be a solution.

5 Likes

Thank you for your solution, I mean well I’m trying to make my game safer, do you know maybe how to make my game safer, because I use plenty of GUIs.

1 Like