Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I retrieve functions from a module script using a client-server foundation?

Asked by
Wiscript 622 Moderation Voter
4 years ago

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

0
There is no point in trying to hide your code from exploiters - they can still see all your client code. programmerHere 371 — 4y
0
Not necessarily, if I worked the code around module scripts hidden in ServerStorage, exploiters wouldn't be able to see that Wiscript 622 — 4y
0
@rodrigo455 What you should do is split what you need to be seen by the client and server into different modules. Exploiters can abuse your Remote Functions to get contents of the module script you returned. They are also able to read your local scripts so it doesn't matter if you destroy the RemoteFunctions because they can just create one. BlackOrange3343 2676 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

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.

0
As for solving it, you could just require the module inside of replicatedstorage from the client itself, otherwise good luck trying to make something invisible to exploiters but not the client. CeramicTile 847 — 4y
0
I wonder why this has a downvote. It's correct. References to functions canNOT be passed through remotes. +1 programmerHere 371 — 4y
Ad

Answer this question