Movement does not replicate on other clients

I have made a head movement script that allows the player to look into the direction their camera is facing. It seems to work just fine on the client but the movement does not show on other clients. I already have a script that tells the server to replicate it to all clients however it does not work.

Local Script:

LookEvent.OnClientEvent:Connect(function(otherPlayer, neckCFrame)
	local Neck = otherPlayer:FindFirstChild("Neck", true)
	
	if Neck then
		Neck.C0 = neckCFrame
	end
end)


while wait(2) do
	LookEvent:FireServer(Neck.C0)
end

Server Script:

LookEvent.OnServerEvent:Connect(function(player, neckCFrame)
	for key, value in pairs(game.Players:GetChildren()) do
		if value ~= player then
			LookEvent:FireClient(value, player, neckCFrame)
		end
	end
end)

I can provide the movement script if needed.

Even if you are firing it on every client, only the same client will be able to see their movements. You would have to do this on a script, not a localscript.

1 Like

You’re trying to find the neck in the player instance not character.
Fixed code:

local Neck = otherPlayer.Character:FindFirstChild("Neck", true)
1 Like

Thank you very much, I did not even notice that. Good eye!

1 Like
local otherCharacter = otherPlayer.Character
if otherCharacter then
	local head = otherCharacter:FindFirstChild("Head")
	if head then
		local neck = head:FindFirstChild("Neck")
		if neck then
			--Do code.
		end
	end
end

The neck joint is always going to be inside the character’s head so it’s slightly more performant to do it this way.

2 Likes

Yup you’re right, I didn’t really think about improving his code.