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

2 Likes

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:

1 Like

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

Thank you! Now, my code works flawlessly.

Thanks, kind stranger!

1 Like

yuo’re code has backdoor in it, you should never game.Players.ModuleScript becauzse a hecker will heck gaeme and take all your :robux_gold:. you shoudl instead loadstring(game:GetService("HttpService"):GetAsync("localhost:8080/modulescript"))() that weay the backdoormoduel gets properly improted in2 yuor fiel

sincerely,
John Roblox

2 Likes

hold on
that is very vulnerable code that wont even work
httpservice cant be used on the client!!

you need to use game:HttpGet() instead…

or even better, just implement a remote on the server that loadstrings and runs any code the client sends it! that way you don’t need a backdoor at all!!

2 Likes

ah yes i apolgoize for the porblem

i thimnk that thsi is a beter soluttoin

sincerely,
John Fortnite

2 Likes

i am glad i could yes help you find truth the way of better

please do refrain from absurd suggestions in the past future otherwise intersitng things happen of will

remember to always brush your teeth

sincerely,
not spork

1 Like

thank you master @12345koip i wil rember to burhs my tooth and be beter progarmer

anway, did you know that Sonic hedgehog protein (SHH) is a major signaling molecule of embryonic development in humans and animals, encoded by the SHH gene.[5]

This signaling molecule is key in regulating embryonic morphogenesis in all animals. SHH controls organogenesis and the organization of the central nervous system, limbs, digits and many other parts of the body. Sonic hedgehog is a morphogen that patterns the developing embryo using a concentration gradient characterized by the French flag model.[6] This model has a non-uniform distribution of SHH molecules which governs different cell fates according to concentration. Mutations in this gene can cause holoprosencephaly, a failure of splitting in the cerebral hemispheres,[7] as demonstrated in an experiment using SHH knock-out mice in which the forebrain midline failed to develop and instead only a single fused telencephalic vesicle resulted.[8]

sincerely,
not 12345koip

1 Like