Hi, programmers!
So basically I'm trying to do a local script that rotates the hands and head to the mouse, but I got stuck here ...
https://ctrlv.tv/eIY7 <= My problem
My scripts:
local player = game.Players.LocalPlayer --local script in starterGui local mouse = player:GetMouse() game:GetService("RunService").RenderStepped:Connect(function() mouse.TargetFilter = workspace player.Character.Torso.Neck.C1 = CFrame.new() player.Character.Torso.Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin((mouse.Hit.p - mouse.Origin.p).unit.y), 0, 0) player.Character.Torso:WaitForChild("Left Shoulder").C1 = CFrame.new() player.Character.Torso:WaitForChild("Left Shoulder").C0 = CFrame.new(1.5, 0, 0) * CFrame.Angles(math.asin((mouse.Hit.p - mouse.Origin.p).unit.y), 0, 0) player.Character.Torso:WaitForChild("Right Shoulder").C1 = CFrame.new() player.Character.Torso:WaitForChild("Right Shoulder").C0 = CFrame.new(-1.5, 0, 0) * CFrame.Angles(math.asin((mouse.Hit.p - mouse.Origin.p).unit.y), 0, 0) end)
thank you in advance for your help ;)
Insert a local script in StarterPlayer inside of StarterPlayerScripts and type this
local script in StarterPlayerScripts
--get service. local cam = workspace.CurrentCamera local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() local hrp = char:WaitForChild("HumanoidRootPart") local neck = char:FindFirstChild("Neck", true) local y = neck.C0.Y --main script game:GetService("RunService").RenderStepped:Connect(function() if neck then --moves head to the direction of the camera local camDirection = hrp.CFrame:ToObjectSpace(cam.CFrame).LookVector neck.C0 = CFrame.new(0, y, 0) * CFrame.Angles(0, -camDirection.X, 0) * CFrame.Angles(camDirection.Y, 0, 0) end end)
Sorry, but this script is rotating only head, and wrong way..