LocalScript to ModuleScript Info Transfer Problems

So basically what I am trying to do is send information from a client to the module script which will then send information back to a local script. I’m not exactly sure what I am doing wrong. But here is my scripts:

– local script 1:

local plr = game.Players.LocalPlayer
local rs = game.ReplicatedStorage
local reward = 500
script.Parent.MouseButton1Click:connect(function()
   rs.Event:FireServer(plr,reward)
end)

– local script 2:

local rs = game.ReplicatedStorage
rs.Event.OnServerEvent:connect(function(plr,reward)
  rs.Event2:FireClient(plr,reward)
end)

Any tips?

Are these both really local scripts? Local scripts can’t handle server code. FireClient is something only the server is meant to use.

Expanding on that–If it’s two LocalScripts, you can use a BindableEvent instead. If your second script is actually a ModuleScript, you don’t even need Bindables/Remotes. Just create and export a function to handle it.

Nope sorry, the second script is a module script.

The ModuleScript is located in ServerScriptService so whenever I call it from a localscript it says that it doesn’t exist.

Don’t send the player as the first argument, roblox does that on its own

1 Like

ServerScriptService doesn’t exist on the client. That’s why you use RemoteEvents inside ReplicatedStorage.

You need a Script on the server side that receives data from your RemoteEvent when it’s fired.

1 Like

This worked. I was unaware I did that. Thank you.

1 Like