Get type that requiring Function from ModuleScript

Hi, I was making module script and I need to get type that require ModuleScript. Is it possible?

For a Example:
require(scritp.Parent).Printf()

--
local RequireType = requireModule.Type() -- I get type of Script that require ModuleScript 
local Local = Enum.RequireType.LocalScript
local Server = Enum.RequireType.Script
--

local module = {}

function module.Printf()
      if RequireType == Local then
          print("Local!")
      elseif RequireType == Server then
          print("Server!")
      else
          print("ModuleScript!")
      end
end

return module
2 Likes

You can use
game:GetService("RunService"):IsClient()
or
game:GetService("RunService"):IsServer()
to detect if it was ran on client or server

2 Likes

Did you mean :IsClient() and :IsServer()?

1 Like

Yeah, sorry, was writing on phone

local RNS = game:GetService("RunService")

local module = {}

function module.Printf()
	if RNS:IsClient() then
		print("Local!")
	elseif RNS:IsServer() then
		print("Server!")
	else
		print("ModuleScript!")
	end
end

return module
2 Likes

Ok please Edit it and I will make it Solution