Camera to head + Animation head rotation = spinning

Hi, I currently have two functions in my script for first person visibility (normal gameplay) and headlock visibility (custom animations).

At a first glance, the code seems fine, but there is a major issue when an animation causes the characters head to rotate right or left while in headlock visibility. Essentially, the game will freak out and think the player is turning their mouse left or right, which causes their entire body to start spinning.

I’ve tried multiple solutions, and even ChatGPT, but I can’t quite figure out how to fix it. Solutions I’ve tried include:

  • Setting DeltaMouseSensitivity to 0
  • Locking the HRP
  • Locking the camera’s rotation (don’t want that because I want the head to rotate with the anim, but not spin!

Here’s the code:

function FirstPersonVisibility()
	
	for _,Obj in pairs(Character:GetDescendants()) do
		
		if Obj:IsA("BasePart") and Obj.Name ~= "Head" and Obj.Name ~= "HumanoidRootPart" and Obj.Parent == Character then
			Obj.LocalTransparencyModifier = 0
			Obj.Transparency = 0
		end
		
		if Obj:IsA("BasePart") and Obj.Parent ~= Character then
			Obj.Transparency = 0
		end
	end
	
	Camera.CameraType = Enum.CameraType.Custom
	Character.Humanoid.CameraOffset = Vector3.new(0,workspace.CurrentCamera.CFrame.LookVector.Y,-1)
end

function HeadLockVisibility()
	
	for _,Limb in pairs(Character:GetChildren()) do
		
		if Limb:IsA("BasePart") and Limb.Name ~= "Head" then
			Limb.LocalTransparencyModifier = 0
		end
		
		if Limb:IsA("Accessory") then
			Limb.Handle.LocalTransparencyModifier = 1
		end
	end
	
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = Character.Head.CFrame * CamShakeCFOffset
end

And here’s the issue:


Did you remember to disable AutoRotate for the Players Humanoid? The Character will rotate to face the camera when in Firstperson mode.

1 Like

Completely forgot this was a property! Thank you, ChatGPT and myself must be very slow.

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