Server/Client exclusive functions in a ModuleScript

What’s up DevForum? I got a quick question.

Can a single ModuleScript store multiple functions where some of its functions can only be used by the client and some of its functions can only be used by the server? And if this is the case, I have multiple questions:

  • Is there a more efficient/more organized solution compared to this setup?
  • Would exploiters be able to see the server-sided functions within the ModuleScript, given that the ModuleScript is placed inside ReplicatedStorage.

Here’s a snippet of what I’m trying to explain:

local Module = {}

local RunService = game:GetService("RunService")

if RunService:IsClient() then
	function Module.FunctionForClientOnly()
		return true
	end
end

if RunService:IsServer() then
	function Module.FunctionForServerOnly()
		return true
	end
end

return Module

Edit: For more context, I wanted to revamp my game. My game has abilities players can use when they’re fighting against boss raids. The Client-sided code creates the visuals, detects if any mobs are hit, loads the animations, and other client-related stuff to make the visuals appear as smooth as possible. The Server-sided code would be needed to deal with all of the logic, such as verifying which mobs were hit by the attack, damage logic, etc.

Yes, they would be able to see the server portion of the code since it’s replicated.

The more organized solution is just to keep them (the visuals and the server checks) apart since they do different things.

1 Like