I have a head movement script in my game that changes players’ heads on the server and client. For some reason unknown to me if a player’s camera CFrame is changed, The player with the altered camera CFrame won’t see any of the other player’s heads moving.
The way the script work is it changes the head on the client, then every few seconds it sends the players head position to the server and then the server sends it to all the clients besides the one it came from.
I have narrowed the bug down and I have found that nothing goes wrong until player head information gets to a player with an altered camera CFrame and then it won’t work on their client.
Here is the client head movement script (this handles the sending and receiving of head position information):
local tweenService = game:GetService("TweenService")
local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
repeat wait(0) until Character ~= nil
local Root = Character:WaitForChild("HumanoidRootPart")
local Neck = Character:WaitForChild("Head"):WaitForChild("Neck")
local CFNew, CFAng = CFrame.new, CFrame.Angles
local asin = math.asin
game:GetService("RunService").RenderStepped:Connect(function()
local CameraDirection = Root.CFrame:toObjectSpace(Camera.CFrame).lookVector
if Neck and Neck.C0.Y then
if Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
Neck.C0 = CFNew(0, Neck.C0.Y, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), 0, 0)
end
end
end)
game.ReplicatedStorage.Misc.Look.OnClientEvent:Connect(function(otherPlayer, neckCFrame)
local Neck2 = otherPlayer.Character:WaitForChild("Head"):WaitForChild("Neck")
if Neck2 then
tweenService:Create(Neck2, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0), {C0 = neckCFrame}):Play()
end
end)
if Player:GetRankInGroup(5565609) == 3 or Player:GetRankInGroup(5565609) == 255 then
while wait(1.5) do
if Neck.C0 then
game.ReplicatedStorage.Misc.Look:FireServer(Neck.C0)
end
end
end
Here is the server script:
game.ReplicatedStorage.Misc.Look.OnServerEvent:Connect(function(player, neckCFrame)
for key, value in pairs(game.Players:GetChildren()) do
if value.Character and value.Character.Head then
if value ~= player and (value.Character.Head.Position - player.Character.Head.Position).Magnitude < 10 then
print(value, player, neckCFrame)
game.ReplicatedStorage.Misc.Look:FireClient(value, player, neckCFrame)
end
end
end
end)