Hey there, I have a pretty straightforward LocalScript that points the neck joint towards the cursor.
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = Players.LocalPlayer:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local torso = character:WaitForChild("Torso")
local neckJoint = torso:FindFirstChild("Neck")
local function updateNeckJoint()
if neckJoint then
neckJoint.C0 =
CFrame.new(0, 1, 0) *
CFrame.Angles(
math.rad(90) + math.asin((mouse.Hit.Position - mouse.Origin.Position).Unit.Y),
math.rad(180),
math.rad(0)
)
end
end
RunService.RenderStepped:Connect(updateNeckJoint)
It works completely fine on the client, but it doesn’t replicate to other players or to the server. I can’t seem to find the reason why anywhere. My memory was that the client has network authority over the character, and this would replicate.
Is there another solution that doesn’t resort to using a remote event? Thanks!
I think that replication is for basic movement (pos & rot of char model) and physics and triggering animations that also exist on the server. If the kind of change you described were replicated automatically, then clients would be able to send whatever actions they wanted their character to perform to all players, which is prob not ideal.
Specific bone rotation like that prob requires a remote event.
Or maybe you could have neck-specific animations for each axis. Something like a full turn and then pause the animation part way on the client to show partial turn. idk. I’d have to play around with it to see what was possible. More thinking out loud than another solution. Pretty sure replicated head-turning is possible. Someone will know how! XD
Personally I would use unreliable remote events for this kind of stuff because that’s exactly what they’re designed for. The most basic implementation would involve simply sending a CFrame to the server every heartbeat which will only take up about 1.5 kB/s per player (a single CFrame takes up a bit more than 20 bytes of memory). You could optimize this for dozens of players in a server by sending a buffer made up of a number or two representing the angle of the player’s head.