Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would i fire a remote event from a module script?

What i am trying to do, is fire off a remote event from my module script in replicated storage. The script works fine, no errors but it doesn't fire the action. Here is an example of what i am trying to do:

function Testfunction()
 game.ReplicatedStorage.remoteevent:FireServer

 return

end

This is just an example. When this is fired, it does everything else i code it to do except fire the remote event.

What other way could i do this?

Any help is appreciated :)

2 answers

Try to do this

local module = {}

module.Function = function(plrInput)
     print(plrInput)
end

return module

and on another server script

local module = require(game.ServerScriptService.ModuleScript) --Change it to your Module Script Position


MyRemoteEvent.OnServerEvent:Connect(module.Function)

And you can call it on a local script,hope it helps

You would basically fire it the same way that you would in a normal script only you would return stuff. Returning doesnot replicate.

Return it on a local script, and pick it up on a script. require the module and call an OnServerEvent:Connect(module.Function) after localizing module above, it's kinda the same but different args have to be passed.

This discussion is preserved as it was. New answers, comments, and votes are closed.