I recently created a script that makes the character’s upper torso move up and down with the camera, so that any tool it has equipped always points towards the camera. It does this by modifying the waist’s Motor6D.
the problem is that despite the code being run on the client side, in a renderStepped function. the movement lags behind the camera and moving it too fast causes it to spaz out. I expected it to be completely smooth since there should be no latency. is there something i can to remove it? Here’s the code:
local cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
--local look = game:GetService("ReplicatedStorage").Look
local char = plr.Character or plr.CharacterAdded:Wait()
local upperTorso = char:WaitForChild("UpperTorso")
local hrp = char:WaitForChild("HumanoidRootPart")
local head = char:WaitForChild("Head")
local waist = upperTorso:WaitForChild("Waist")
local y = waist.C0.Y
RunService:BindToRenderStep("UpdateLoop", Enum.RenderPriority.Camera.Value + 1, function()
if waist then
local camDirection = cam.CFrame.LookVector
local angle = math.deg(camDirection:Angle(hrp.CFrame.LookVector, cam.CFrame.RightVector))
--look:FireServer(angle)
waist.C0 = CFrame.new(0, y, 0) * CFrame.Angles(math.rad(-angle),0,0)
end
char.Humanoid.CameraOffset = (hrp.CFrame + Vector3.new(0, 1.5, 0)):PointToObjectSpace(head.Position)
end