Custom Remote Event [FIXED]

UPDATE : the problem just comes from the name of the module which was “Remotes” which I modified by “RemoteModule” :slight_smile:

I am currently creating a secure remote module with a “Hash” name, (HashLib) But I don’t understand something because on the client side it creates the event for me as required but as soon as I call the module on the client side server I get the following error:

Attempted to call require with invalid argument(s).

To tell you everything, I searched the forums and couldn’t find anything :face_holding_back_tears:

There is the module :

local replicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local Libraries = replicatedStorage:WaitForChild("Librairies")

local hasLib = require(Libraries.HashLib)

local Remotes = {}

function Remotes.Event(RemoteName)
	local EncryptedName = hasLib.bin_to_base64(hasLib.hex_to_bin(hasLib.sha1(RemoteName)))
	if not script:FindFirstChild(EncryptedName) then
		local RemoteEvent = Instance.new("RemoteEvent")
		RemoteEvent.Name = EncryptedName
		RemoteEvent.Parent = script	

		return RemoteEvent
	end	
	
	local RemoteInstance = script:WaitForChild(EncryptedName, 4)
	if RemoteInstance == nil then error("Couldn't get RemoteEvent " .. RemoteName, 2)	end
	return RemoteInstance
end

return Remotes

here is an example of how I subsequently call the client and server module

-- Client
local remoteModule = require(replicatedStorage.Remotes)
local name = "John"

remoteModule.Event("Name"):FireServer(name)

-- Server
local remoteModule = require(replicatedStorage.Remotes)

remoteModule.Event("Name").OnServerEvent(player, name)
   print(`{player.Name} --> {name}`)
end)

the error occurs when I call the server side module
If anyone could help me I would be indebted! :pleading_face:

1 Like

Whatever happens on the client wont affect the server side. Do you’d need to create the event from the server, not the client.