How do I run a fireserver in a modulescript? (or something similar)

I need to learn how to run fireserver inside of a module script my script:

RemoteEvent:FireServer(Plr, Message)

(what it does is make a player say something)

Just out of curiosity, why doesnā€™t the code you posted work inside a ModuleScript? I believe it should function normally, as long as you reference the RemoteEvent correctly.

1 Like

image

Are you requiring the module from a Server, or Local Script? Essentially happens when you require() a ModuleScript, is it loads the ModuleScript code into into the LocalScript/ServerScript you required it from for use.

2 Likes

i am requiring from a module script

What is requiring the module that is requiring the module? ModuleScriptā€™s do not run unless they are called to by a Server or Local Script.

1 Like

i require it my executing it in the f9 console

Are you executing it to run on the Server, or the Client? Can I see where you are running it exactly?

1 Like

yes but i donā€™t know exactly what you mean

He said he was doing it from the DevConsole, so the server, OP I suggest you use BindableEvents then

1 Like

how would I do that exactly? I donā€™t know how

Show me the code then, so I can see exactly what it does

1 Like

[ā€œchatā€] = function(ā€¦)

local Arguments = {ā€¦}

if Arguments[1] == ā€œGETINFOā€ then return {"Chat [Plr] [Message] ",ā€œForces a player to chat.ā€,ā€œAdminā€} end

local LocalPlr,ExplodedText = Arguments[1],Arguments[2]

local Targets = ConvertPlayersFromText(ExplodedText[1],LocalPlr)

local Message = ā€˜ā€™

for I,Text in pairs(ExplodedText) do

if I ~= 1 then

Message = Messageā€¦(Text)

end

if I < #ExplodedText and I > 1 then

Message = Messageā€¦" "

end

end

for _,Plr in pairs(Targets) do

local lol = script.Items.chathax.Message

lol.Value = Message

script.Items.chathax.RemoteEvent:FireServer(Plr, Message.Value)

end

end,

The developer console runs code on the server, so you canā€™t use a RemoteEvent.

Instead of using a RemoteEvent which is for client to server communication, use a BindableEvent, whoā€™s perpose is to send information from server to server.

To fire the event you use:

BindableEvent:Fire(Plr, Message)

To receive the event you use:

BindableEvent.Event:Connect(function(Plr, Message)

end)
1 Like

trying it now thanks for helping

1 Like

one problem i need to use onserverevent with the event. Bindable event dosent have that.

You use .Event in the place of .OnServerEvent. It does the exact same thing as .OnServerEvent, but is for BindableEventā€™s.

1 Like