Help with head face mouse rotation

  1. I wan’t to make head face towards cursor

  2. When character turn back mouse inverses look:

  3. I’m looking at dev forum and youtube but nothing help

I: maybe i can’t reply today, but i reply tommorow , i really thank for all ideas how to fix this bug

Can you explain a bit more?

Like:

  • what is the head doing?

  • Are you using Target or hit?

  • What is your script and can you show it?

1 Like

The problem is head on one side turning correctly but on another it inverses

Here is a code:

wait(1)
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local character = plr.Character

local Neck = character:WaitForChild("Head").Neck
local Head = character:WaitForChild("Head")

local Offset = Neck.C0.Y
local origin = Neck.C0


wait(1)
mouse.Move:Connect(function()

		local point = mouse.Hit
	

	--local object_horizontal = Head.CFrame:PointToObjectSpace(point.p) -- Angle beetween mouse, it's for previous tests
		--local yaw = math.atan2(-object_horizontal.X,-object_horizontal.Z)
	
	Neck.C0 = CFrame.new(0,Offset,0) * CFrame.Angles(0,math.asin(mouse.Hit.LookVector.X),0)
	
	

	
	
	
	
end)

I think the problem is that the LookVector value is WorldSpace instead of ObjectSpace relative to the player, correct me if I’m wrong.

1 Like
-- LocalScript in StarterCharacterScripts
script.Parent:WaitForChild("HumanoidRootPart").CFrame:ToObjectSpace(game.Players.LocalPlayer:GetMouse().Hit).LookVector 
-- Calculation to make the lookvector relative.

1 Like

It worked!!!, perfect! you are nice scripter. I have problem with understanding simple things, you know. Sometimes i need to concentrate on smaller things to make bigger one

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.