i found this script on forum and changed it a litbit, but theres a problem. When Torso and Head are following mouse then its visible only for scripts parent, but i want it to be visible to everyone. I tried to write like with remote event, but magnitude didnt work there and idk why
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local Neck = Head:WaitForChild("Neck")
local Torso = Character:WaitForChild("UpperTorso")
local Waist = Torso:WaitForChild("Waist")
local NeckOriginC0 = Neck.C0
local WaistOriginC0 = Waist.C0
Neck.MaxVelocity = 1/3
RunService.RenderStepped:Connect(function()
if Character:FindFirstChild("UpperTorso") and Character:FindFirstChild("Head") then
local TorsoLookVector = Torso.CFrame.lookVector
local HeadPosition = Head.CFrame.p
if Neck and Waist then
if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then
local Point = PlayerMouse.Hit.p
local Distance = (Head.CFrame.p - Point).magnitude
local Difference = Head.CFrame.Y - Point.Y
Neck.C0 = Neck.C0:lerp(NeckOriginC0 * CFrame.Angles(-(math.atan(Difference / Distance) * 0.7), (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0), 0.5 / 2)
Waist.C0 = Waist.C0:lerp(WaistOriginC0 * CFrame.Angles(-(math.atan(Difference / Distance) * 0.5), (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0), 0.5 / 2)
end
end
end
end)
Why do you think the head only moves on the client?
I tested and turns out, they don’t replicated to server
so you need somehow make them replicated in server
I’m pretty sure you did something like this:
Remote:FireServer(Neck.C0, Waist.C0, Neck_New_Magnitude, Waist_New_Magnitude)
And on Server:
Neck = Neck_New_Magnitude and Waist = Waist_New_Magnitude
It did not work because you sent the infomation of .C0 with Waist.C0, so you’ll have to send the Neck and Waist Motor6D to the server instead so server will modify it directly.
Try this, tell me if it did not work:
-- Paste this in your current cilent script
local Remote = --Remote event path here
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local Neck = Head:WaitForChild("Neck")
local Torso = Character:WaitForChild("UpperTorso")
local Waist = Torso:WaitForChild("Waist")
local NeckOriginC0 = Neck.C0
local WaistOriginC0 = Waist.C0
Neck.MaxVelocity = 1/3
RunService.RenderStepped:Connect(function()
if Character:FindFirstChild("UpperTorso") and Character:FindFirstChild("Head") then
local TorsoLookVector = Torso.CFrame.lookVector
local HeadPosition = Head.CFrame.p
if Neck and Waist then
if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then
local Point = PlayerMouse.Hit.p
local Distance = (Head.CFrame.p - Point).magnitude
local Difference = Head.CFrame.Y - Point.Y
local Neck_C0 = Neck.C0:lerp(NeckOriginC0 * CFrame.Angles(-(math.atan(Difference / Distance) * 0.7), (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0), 0.5 / 2)
local Waist_C0 = Waist.C0:lerp(WaistOriginC0 * CFrame.Angles(-(math.atan(Difference / Distance) * 0.5), (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0), 0.5 / 2)
Remote:FireServer(Neck_C0, Waist_C0, Neck, Waist)
end
end
end
end)
-- Create a Normal Script and put it inside ServerScriptService, finally paste this in
local Remote = --Remote event path here
Remote.OnServerEvent:Connect(function(Neck_C0 : Vector3, Waist_C0 : Vector3, Neck : Motor6D, Waist : Motor6D)
Neck.C0 = Neck_C0
Waist.C0 = Waist_C0
end)
okay, i changed it a litbit and now it works, but it look very glitchy in the game.
Oh sorry my bad, then we will send the info to client to change it for us instead.
-- Paste this in your current cilent script
local Remote = --Remote event path here
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local Neck = Head:WaitForChild("Neck")
local Torso = Character:WaitForChild("UpperTorso")
local Waist = Torso:WaitForChild("Waist")
local NeckOriginC0 = Neck.C0
local WaistOriginC0 = Waist.C0
Neck.MaxVelocity = 1/3
RunService.Heartbeat:Connect(function()
if Character:FindFirstChild("UpperTorso") and Character:FindFirstChild("Head") then
local TorsoLookVector = Torso.CFrame.lookVector
local HeadPosition = Head.CFrame.p
if Neck and Waist then
if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then
local Point = PlayerMouse.Hit.p
local Distance = (Head.CFrame.p - Point).magnitude
local Difference = Head.CFrame.Y - Point.Y
local Neck_C0 = Neck.C0:lerp(NeckOriginC0 * CFrame.Angles(-(math.atan(Difference / Distance) * 0.7), (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0), 0.5 / 2)
local Waist_C0 = Waist.C0:lerp(WaistOriginC0 * CFrame.Angles(-(math.atan(Difference / Distance) * 0.5), (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0), 0.5 / 2)
Neck.C0 = Neck_C0
Waist.C0 = Waist_C0
Remote:FireServer(Neck_C0, Waist_C0, Waist, Neck)
end
end
end
end)
Remote.OnClientEvent:Connect(function(Player_Sended, Neck_C0, Waist_C0, NeckNeededToChanged, WaistNeededToChanged)
if Player_Sended ~= Player then
NeckNeededToChanged.C0 = Neck_C0
WaistNeededToChanged.C0 = Waist_C0
end
end)
And the server
local Remote = --Remote event path here
Remote.OnServerEvent:Connect(function(Player, Neck_C0 : Vector3, Waist_C0 : Vector3, Neck : Motor6D, Waist : Motor6D)
warn(Neck, Waist)
Remote:FireAllClients(Player, Neck_C0, Waist_C0, Neck, Waist)
end)
now it should work smoothly, we just made the server call the cilent to change the body instead of the server for less lagging.