Modulescript run on my server and client help

I have a module script that fulfills a single function that spans both contexts. For personal organization purposes it is contained in a single modulescript.
Though I wish to require ServerScriptService and use it on the server side the local variables I create for SSS descendants break the client’s usage as these calls are established outside of the context of when the module’s :serverSide() or :clientSide() functions are used, and for which :serverSide() they are provided.
The easy improper solution of course is to simply put them into the serverSide component(s) of this module that is required by both separate client and separate server, but it is messy and I wish to do an external “if then” on the prefab locals like “if server then local thingForServer =…”. I’m just not sure how.

If its a module used both by client and server you could simply just put it inside ReplicatedStorage and then both client and server can have access to the module

This is not what I asked. I want to know how to identify which side the modulescript is being ran by from inside itself, to some extent.

1 Like

RunService has a method for this! There’s RunService:IsClient() and RunService:IsServer(). They both return a boolean.

1 Like