Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

4 comments

0

Run an if statement before requiring the ModuleScript to check if the parent is in a client based service.

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.

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.

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.

1 answer

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..

2 comments

1

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

0

Thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.