Need help with head moving system

So I did make arm moving, however, when I try make head moving, it ended up move right and left. I want is make head look up and down.

local rightX, rightY, rightZ = char.Torso["Right Shoulder"].C0:ToEulerAnglesYXZ()
		char.Torso["Right Shoulder"].C0 = (char.Torso["Right Shoulder"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((mouse.Hit.p - mouse.Origin.p).unit.y))
		char.Torso["Neck"].C0 = (char.Torso["Neck"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((mouse.Hit.p - mouse.Origin.p).unit.y))

so you can use mouse.hit.lookvector or camera.cframe.lookvector*2048 to also make the character look at those points but it would be a bit unrealistic

Is this? Because when I try to put but is not working.

local rightX, rightY, rightZ = char.Torso["Right Shoulder"].C0:ToEulerAnglesYXZ()
		char.Torso["Right Shoulder"].C0 = (char.Torso["Right Shoulder"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((mouse.Hit.p - mouse.Origin.p).unit.y))
		char.Torso["Neck"].C0 = (char.Torso["Neck"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((mouse.hit.lookvector or camera.cframe.lookvector*2048).unit.y))

can you wait a bit till i get my code that does that

Alright. I wait you when you done.

Do you want headturn and the ability to make your head move up and down?

local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local Character = Player.Character or Player.CharacterAdded:Wait()
local Root = Character:WaitForChild("HumanoidRootPart")
local Neck = Character:FindFirstChild("Neck", true)
local YOffset3 =  Neck.C0.Y

game:GetService("RunService").RenderStepped:Connect(function()
	local CameraDirection = Root.CFrame:toObjectSpace(Mouse.Hit).lookVector
	Neck.C0 = CFrame.new(0, YOffset3, 0) * CFrame.Angles(0, -math.asin(CameraDirection.X), 0) * CFrame.Angles(math.asin(CameraDirection.Y), 0, 0)	end
end)
1 Like

pretty sure that is exactly what he just said

There is problem, after I run, the head somehow turn wrong way.

can u send a video please? thanks

here

local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local Character = Player.Character or Player.CharacterAdded:Wait()
local Root = Character:WaitForChild("HumanoidRootPart")
local Neck = Character:FindFirstChild("Neck", true)
local YOffset3 =  Neck.C0.Y

game:GetService("RunService").RenderStepped:Connect(function()
	local CameraDirection = Root.CFrame:toObjectSpace(Camera.CFrame).lookVector
	Neck.C0 = CFrame.new(0, YOffset3, 0) * CFrame.Angles(0, -math.asin(CameraDirection.X), 0) * CFrame.Angles(math.asin(CameraDirection.Y), 0, 0)
end)

the old code was mouse sided not camera sided

robloxapp-20220318-2142205.wmv (1.1 MB)

These two methods I used and still not work.

oh this is cuz its for r15 watch this for help Server Side Head/Camera Movement (R6/R15) - Roblox (Remote Events and Tweening) - YouTube

1 Like

Alright. I gonna watch it later. I have more thing to do.

well it does have code in desc but k

Thank you, your code is worked for me

Love your script. Very cool. Thank you for sharing.