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

Detect if a ModuleScript was 'required' from a Client or Server?

Asked by 6 years ago

I'm making an Anti-Exploit, but I'm wondering is there anyway that this is possible

From Server:

M = require "ModuleScript"
M.output("hi")

Console Output: hi

From Client

M = require "ModuleScript"'
M.output("hi")

Console Output: XX:XX:XX.XXX script:2 ModuleScript can only be called in a Server side script

Anyone help?

SirTomHamishWatson; Team Neoprene Head Programmer

0
Run an if statement before requiring the ModuleScript to check if the parent is in a client based service. PyccknnXakep 1225 — 6y
0
@PyccknnXakep That is not what he wants. He wants an anti exploit to detect if a exploit or the localscript fired the module script. hiimgoodpack 2009 — 6y
0
What you could do, is send a little random password as a parameter for your module script, and if the password is incorrect, the module script could just not run the stuff. hiimgoodpack 2009 — 6y
0
If you're going to prevent the client from running the module, just leave the script in server storage, so the client can't access it. LifeInDevelopment 364 — 6y

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
6 years ago
Edited 6 years ago

A simple way to do this would be to check if the LocalPlayer exists or not.

You can only access the LocalPlayer on the client

The module would look like this:

local module = {}; --Define module table

module.output = function(blah) --Define a new 'print' function
    local p = game.Players.LocalPlayer;
    if p then --Check if LocalPlayer exists
        --If it does exist, the module was called on the client
        warn("ModuleScript can only be called in a Server side script");
    else --If not, the module was called on the server
        print(blah);
    end
end

return module;

You could also do this by checking if ServerStorage exists, since it can only be accessed on the server..

1
You could also do this by checking if ServerStorage exists, since it can only be accessed on the **server**. CaptinLetus 6 — 6y
0
Thanks. Goulstem 8144 — 6y
Ad

Answer this question