Trying to get the top of my tank to rotate with mouse using neck rotation... It works at origin but upon moving it starts to get funky. Any ideas?
https://streamable.com/dylleu
local RunService = game:GetService("RunService") local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local Character = Player.Character or Player.CharacterAdded:Wait() local HRP = Character:WaitForChild("HumanoidRootPart") local Neck = Character:FindFirstChild("Neck", true)
Mouse.Move:Connect(function() local mouseframe = CFrame.new(Mouse.hit.Position.X, 0, Mouse.hit.Position.Z) local dir = HRP.CFrame:ToObjectSpace(mouseframe).LookVector Neck.C0 = CFrame.new(Neck.C0.Position, Vector3.new(Mouse.hit.Position.X, Neck.C0.Position.Y, Mouse.hit.Position.Z)) * CFrame.Angles(math.rad(-90), 0, math.rad(180)) * CFrame.Angles(0, dir.Y, 0) end)