Hi! I wrote a code that basically makes a player rotating/bending towards the mouse position. Everything works great except of one Bugg, weird shaking when I hover the right arm with my mouse. Here is a video: robloxapp-20200727-2305496.wmv (2.3 MB) and here is my script:
local plr = game:GetService("Players").LocalPlayer
local ms = plr:GetMouse()
local waist = plr.Character:FindFirstChild("Waist", true)
local defPos = waist.C0.Y
local root = plr.Character:FindFirstChild("HumanoidRootPart")
local cf, v3 = CFrame, Vector3
game:GetService("RunService").RenderStepped:Connect(function()
print(root.CFrame.p)
---------- ROTATING OF WAIST ---------
local dif = (root.CFrame.p - ms.Hit.p)
local look = (root.CFrame.upVector)
local angle = math.acos((dif:Dot(look) / dif.Magnitude * look.Magnitude))
waist.C0 = cf.new(0, defPos, 0) * cf.Angles(angle - math.pi / 2, 0, 0)
-------- ROTATING OF A PLAYER ----------
local direction = (ms.Hit.p - root.Position) * v3.new(1, 0, 1)
root.CFrame = cf.new(root.Position, root.Position + direction)
end)
Thanks for help!