Help with custom remote module

Hi, everybody. Today, something horrible happened to me—my code didn’t work. I don’t understand, why? Why does it not work? Please, someone, tell me.

I am trying to achieve a custom Remote module to make two-way communication easier.
The following is the ModuleScript code:

local module={

function module.FireRemote(remote:remoteevent,data,target:player)
  if game:service'RunService':IsClient then
    remote:FireServer(data)
  else
    remote : fireClients(target,data)
  end;
end

The following is the LocalScript code:

local module = game.Players.ModuleScript
require(module)
module:FireRemote(ReplicatedStraga:remoteevent
{amouny=5} game.Players.LocalPlayer)

Why, why did this have to happen to me… Just why… I don’t understand. What is wrong? Someone, save me… please…
My gratitude upon you all in advance.

3 Likes

Hello, your entire module script is broken [syntax, capitalization and method usage]
module = { is not closed
you used function module.FireRemote(…) inside a table that hasnt been defined fully yet
remote : fireClients is an incorrect method name
RunService:IsClient is a method, not a property

do it like this:

local RunService = game:GetService("RunService")

local module = {}

function module.FireRemote(remote: RemoteEvent, data: any, target: Player?)
	if RunService:IsClient() then
		remote:FireServer(data)
	else
		if target then
			remote:FireClient(target, data)
		else
			remote:FireAllClients(data)
		end
	end
end

return module

So is ur local script [syntax,require usage and typos]

too lazy to point out ur mistakes but heres the fixed code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteHandler = require(ReplicatedStorage:WaitForChild("RemoteHandler"))

local remote = ReplicatedStorage:WaitForChild("MyRemoteEvent") 

RemoteHandler.FireRemote(remote, {amount = 5}, game.Players.LocalPlayer)

i tried your code in my studio and it worked, just try uninstalling and reinstalling

1 Like

ModuleScript code:

local modual={

function modual.FireRremote(remote: remot3event,data, trarget:playr)
  if game:servce'RunSerivce':IsClint then
    rremote::FireSserver(data)
  else
    rremote . fireClients(trarget dat)
  end;
ennd

LocalScript code:

local module = game.Players.ModuleScript
require(module)
module:FireRemote(ReplicatedStraga:remoteevent
{amouny=5} game.Players.LocalPlayer)

workspace:ClearAllChildren()

Your scripts have been expertly fixed! They should now be running at peak efficiency. Let me know if you need further improvements! :smile:

you monkey moite!!! obv they need to reinstall windows🐒

if this isnt working something is definitely wrong
try reinstalling your bios!!!

he needs to factory reset his pc

2 Likes

he needs to get a macbook atp r

1 Like

oh wait i spotted something else wrong
here is code fixed

local module={

;function module.FireRemote(remote:remoteevent,data,target:player)
  ;if game:service'RunService':IsClient then
    ;remote:FireServer(data)
  ;else
    ;remote : fireClients(target,data)
  ;end
;end
;
3 Likes

Try unplugging and plugging it.

1 Like

He should do this instead in a server script to fix the game;

while true do 
  for i = 1,500000 do
       Instance.new("Part",workspace)
   end
end
1 Like

no
if i have one genuine piece of advice i think he needs to install a backdoor
that should fix it

i mean ur method would too but a backdoor is better for this kind of fix

1 Like

delete system 32 and it should work

also fixed code:

local module={}

function module.FireRemote(remote:RemoteEvent,target:Player?,...)
  if game:GetService("RunService"):IsClient() then
    remote:FireServer(...)
  else
    if target then
        remote:FireClient(target,...)
    else
        remote:FireAllClients(...)
    end
  end
end

return module
local module = game.ReplicatedStorage.ModuleScript
module = require(module)
module:FireRemote(game.ReplicatedStorage.RemoteEvent,{amount=5})

thank me later homie