Instance not receiving on event:FireClient()

Hello,

I am sending these two events in my server script

game.ReplicatedStorage.Remotes.camera:FireClient(sender, chamber.Important.camP1)
game.ReplicatedStorage.Remotes.camera:FireClient(receiver, chamber.Important.camP2)

One for each of the two players involved in the script, and a part for each player that is supposed to act as the camera.

But when it gets to the client part it’s giving me an error. This is the local script:

game.ReplicatedStorage.Remotes.camera.OnClientEvent:Connect(function(Player, cameraPart)
	local Camera = workspace.CurrentCamera
	
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = cameraPart.CFrame
end)

Notes:

  • The problem is not on the server side, i added prints and the parts do exist and everything.
  • The client error says can’t identify CFrame, nil.

Does anyone know how i can fix this? Thanks.

Remove the Player from the OnClientEvent.

You can access local player from the client, no need for the player instance

local player = game.Players.LocalPlayer

game.ReplicatedStorage.Remotes.camera.OnClientEvent:Connect(function(cameraPart)
	local Camera = workspace.CurrentCamera
	
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = cameraPart.CFrame
end)

Ok. Do i also need to remove it from the server script?

Yes, I believe so. charlimitttt

No, only remove it from the OnClientEvent.

1 Like