Does FireClient work inside ModuleScripts?

I’m currently working on my upcoming game, and I’m having a really simple issue that I cannot seem to fix.

I’m requiring my ModuleScript, Game_Functions from a Server Script.

This ModuleScript contains a function that spawns the player and sets them up with things like camera view, and other things.

I call Fix_Camera:FireServer(Player), and the script does everything inside the ModuleScript function, but skips over the FireServer line, doing absolutely nothing on the client side.

I cannot seem to find what is wrong. There isn’t any point in me providing my code structure because the only thing that doesn’t work is FireClient in my ModuleScript.

Edit:
Here is a code structure which is basically how I setup my ModuleScript without giving all my code.

function Game_Functions:Spawn_Player(Player_Arg)
   local ReplicatedStorage = game:GetService("ReplicatedStorage")
   local Remotes = ReplicatedStorage:WaitForChild("Remotes")
   local Fix_Camera = Remotes:WaitForChild("Fix_Camera")
   
   Fix_Camera:FireClient(Player_Arg)
end

Any help would be appreciated! If I get any at all that is.

Try using :FireClient(player)

also is there a local script that is listening for this event?

Yes, there is, right here:

-- This client event will reset the camera back to the Humanoid to prevent a camera glitch on spawn --
Fix_Camera.OnClientEvent:Connect(function()
	print("📷 | Camera Fix was called. Resetting Camera back to the Humanoid...")
	workspace.CurrentCamera.CameraSubject = Humanoid
end)

(fyi, this print statement does not run which is how I know FireClient* is not working)

It could be that the server is firing before the client’s connection is setup.

Try adding a print line before Fix_Camer:FireClient(Player_Arg) to verify it’s running, you can also add a temporary task.wait(3) before firing the client in order to give the system a little more time to load, if it works, then you change the task.wait(3) to something else that better suits your needs but then you’ll know that’s the issue.

Edit:

If you add the print line on the server, and then add another print line on the client, above the line where you establish the connection, then you can compare both of the output timings to see if the server is firing first, or the client is, you want the client to fire first so that the connection is established

2 Likes

I switched the client code to another script and it seems to have fixed the issue, which means the client was not setting up the connection for some reason. It seems you were right.

My system was setup in a way that the ModuleScript function for Spawn_Player would only run if the player clicked the “Play” button

1 Like