Need help with AutoRotate please

Quick question, I have a custom camera system that is set to Scriptable; I also have a wallclimbing script. When the WallClimb attribute is true the Humanoid.AutoRotate is false and vice versa. The issue is when I look on the x-axis the player still follows the camera making the player fall off the wall.

I wanted it so you could look on the x-axis while wallclimbing without the player following the camera. Does having the camera type set to Scriptable and having custom mouse movement somehow override the AutoRotate? If you guys could help me figure out the solution that would be amazing!

Part of my script (not the whole thing):

Input.InputChanged:Connect(function(InputObject)
	if InputObject.UserInputType == Enum.UserInputType.MouseMovement then
		local Delta = Vector2.new(InputObject.Delta.x / Sensitivity, InputObject.Delta.y / Sensitivity) * Smoothness

		local X = TargetAngleX - Delta.y

		if not Player:GetAttribute("WallClimbing") then
			Humanoid.AutoRotate = true
			TargetAngleX = math.clamp(X, -80, 80) -- look up and down
			TargetAngleY = (TargetAngleY - Delta.x) % 360 -- look left and right
		elseif Player:GetAttribute("WallClimbing") then
			Humanoid.AutoRotate = false
			TargetAngleX = math.clamp(X, -80, 80) -- look up and down while wallclimbing
		end
	end
end)

Video:

is TargetAngleY a variable? Maybe set it to nil while the character is wallclimbing?

Just tried it and it didn’t work unfortunately

are you using some sort of custom system to rotate the player?

Ill just post the whole system

script:

repeat wait() until game:GetService("Players").LocalPlayer.Character ~= nil

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Input = game:GetService("UserInputService")
local Players = game:GetService("Players")

CanViewBody = true
Sensitivity = 0.1
Smoothness = 0.075
FieldOfView = 120
HeadOffset = CFrame.new(0, 0, -0.5)

local MinZoom = 0.5 -- minimum zoom distance
local MaxZoom = 10 -- maximum zoom distance
local ZoomSensitivity = 1 -- how fast the zoom changes
local ZoomLevel = MinZoom -- initial zoom level

local Cam = game.Workspace.CurrentCamera
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character.Humanoid
local HumanoidRootPart = Character.HumanoidRootPart

local Head = Character:WaitForChild("Head")
local Torso = Character:WaitForChild("Torso")
local CamPos, TargetCamPos = Cam.CoordinateFrame.p, Cam.CoordinateFrame.p 
local AngleX, TargetAngleX = 0, 0
local AngleY, TargetAngleY = 0, 0

Torso.LocalTransparencyModifier = 1

local Running = true
local FreeMouse = false
local DefaultFOV = FieldOfView

local W, A, S, D, LShift = false, false, false, false, false

local EasingTime = 0.1
local WalkSpeeds = {
	enabled = false;
	walkingspeed = 12;
	backwardsspeed = 6;
	sidewaysspeed = 6;
	diagonalspeed = 12;
	runningspeed = 18;
	runningFOV = 120;
}

function updateCharacter()
	local fullTilt = Player:GetAttribute("FullTilt")

	if CanViewBody then
		for _, Part in pairs(Character:GetDescendants()) do
			if Part.Name == 'Head' or Part.Name == 'Torso' or Part:IsA("Torso") or Part:IsA("MeshPart") or Part:IsA("Accessory") or Part:IsA("Hat") then
				local isFirstPerson = ZoomLevel <= MinZoom or fullTilt

				local transparencyValue
				if fullTilt and (Part.Name == 'Left Arm' or Part.Name == 'Right Arm' or Part.Name == 'Left Leg' or Part.Name == 'Right Leg') then
					transparencyValue = 0 -- make specified parts visible in first person when cam is attached
				else
					transparencyValue = isFirstPerson and 1 or 0
				end

				if not fullTilt and isFirstPerson and (Part.Name == 'Left Arm' or Part.Name == 'Right Arm' or Part.Name == 'Left Leg' or Part.Name == 'Right Leg') then
					transparencyValue = 0 -- make specified parts visible in first person when cam is not attached
				end

				if Part.Name == 'Head' then
					Part.LocalTransparencyModifier = transparencyValue
					--Part.CanCollide = false
					if Part:FindFirstChild("face") then
						Part.face.LocalTransparencyModifier = transparencyValue
					end
				elseif Part:IsA("Accessory") or Part:IsA("Hat") then
					if Part:FindFirstChild('Handle') then
						Part.Handle.LocalTransparencyModifier = transparencyValue
					end
				else
					Part.LocalTransparencyModifier = transparencyValue
					--Part.CanCollide = not isFirstPerson
				end
			end
		end
	end
end

function lerp(a, b, t)
	return a * (1 - t) + (b * t)
end

Input.InputChanged:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseWheel then
		-- check if full tilt is active before zooming
		if not Player:GetAttribute("FullTilt") then
			ZoomLevel = math.clamp(ZoomLevel - input.Position.Z * ZoomSensitivity, MinZoom, MaxZoom)
		end
	end
end)

Input.InputChanged:Connect(function(InputObject)
	if InputObject.UserInputType == Enum.UserInputType.MouseMovement then
		local Delta = Vector2.new(InputObject.Delta.x / Sensitivity, InputObject.Delta.y / Sensitivity) * Smoothness

		local X = TargetAngleX - Delta.y

		if not Player:GetAttribute("WallClimbing") then
			Humanoid.AutoRotate = true
			TargetAngleX = math.clamp(X, -80, 80) -- look up and down
			TargetAngleY = (TargetAngleY - Delta.x) % 360 -- look left and right
		elseif Player:GetAttribute("WallClimbing") then
			Humanoid.AutoRotate = false
			TargetAngleY = (TargetAngleY - Delta.x) % 360 -- look left and right
		end
	end
end)

--controller support
Input.InputChanged:Connect(function(InputObject)
	if InputObject.KeyCode == Enum.KeyCode.Thumbstick2 then
		local StickMovement = InputObject.Position
		local Delta = Vector2.new(StickMovement.x / Sensitivity, StickMovement.y / Sensitivity) * Smoothness
		
		local X = TargetAngleX + Delta.y

		if not Player:GetAttribute("WallClimbing") then
			Humanoid.AutoRotate = true
			TargetAngleX = math.clamp(X, -80, 80) -- look up and down
			TargetAngleY = (TargetAngleY - Delta.x) % 360 -- look left and right
		elseif Player:GetAttribute("WallClimbing") then
			Humanoid.AutoRotate = false
			TargetAngleX = math.clamp(X, -80, 80) -- look up and down while wallclimbing
		end
	end
end)

Input.InputBegan:Connect(function(InputObject)
	if InputObject.UserInputType == Enum.UserInputType.Keyboard then

		if InputObject.KeyCode == Enum.KeyCode.W then
			W = true
		end

		if InputObject.KeyCode == Enum.KeyCode.A then
			A = true
		end

		if InputObject.KeyCode == Enum.KeyCode.S then
			S = true
		end

		if InputObject.KeyCode == Enum.KeyCode.D then
			D = true
		end

		if InputObject.KeyCode == Enum.KeyCode.LeftShift then
			LShift = true
		end
	end
end)

Input.InputEnded:Connect(function(InputObject)
	if InputObject.UserInputType == Enum.UserInputType.Keyboard then
		if InputObject.KeyCode == Enum.KeyCode.W then
			W = false
		end

		if InputObject.KeyCode == Enum.KeyCode.A then
			A = false
		end

		if InputObject.KeyCode == Enum.KeyCode.S then
			S = false
		end

		if InputObject.KeyCode == Enum.KeyCode.D then
			D = false
		end

		if InputObject.KeyCode == Enum.KeyCode.LeftShift then
			LShift = false
		end
	end
end)

local OriginalHeadOffset = HeadOffset

RunService.RenderStepped:Connect(function()
	if Running then
		updateCharacter()

		CamPos = CamPos + (TargetCamPos - CamPos) * 0.28
		AngleX = AngleX + (TargetAngleX - AngleX) * 0.35 
		local Dist = TargetAngleY - AngleY
		Dist = math.abs(Dist) > 180 and Dist - (Dist / math.abs(Dist)) * 360 or Dist 
		AngleY = (AngleY + Dist * 0.35) % 360
		Cam.CameraType = Enum.CameraType.Scriptable
		
		-- this was a shitty fix to make the camera center after finishing a roll
		--[[if Character:GetAttribute("Rolling") then
			spawn(function()
				wait(0.2)
				AngleX = 0
				TargetAngleX = 0
			end)
		end]]

		if ZoomLevel > MinZoom then
			HeadOffset = CFrame.new(1.5, 0, 0)
		else
			HeadOffset = OriginalHeadOffset
		end

		local zoomOffset = CFrame.new(0, 0, ZoomLevel)
		Cam.CoordinateFrame = CFrame.new(Head.Position)
			* CFrame.Angles(0, math.rad(AngleY), 0)
			* CFrame.Angles(math.rad(AngleX), 0, 0)
			* HeadOffset
			* zoomOffset

		HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position) * CFrame.Angles(0, math.rad(AngleY), 0)
	else
		game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default
	end

	if (Cam.Focus.p - Cam.CoordinateFrame.p).magnitude < 1 then
		Running = false
	else
		Running = true
		if FreeMouse then
			game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default
		else
			game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
		end
	end

	Cam.FieldOfView = FieldOfView

	if WalkSpeeds.enabled then
		if W and S then return end

		if W and not LShift then
			FieldOfView = lerp(FieldOfView, DefaultFOV, EasingTime)
			Humanoid.WalkSpeed = lerp(Humanoid.WalkSpeed, WalkSpeeds.walkingspeed, EasingTime)
		elseif W and A then
			Humanoid.WalkSpeed = lerp(Humanoid.WalkSpeed, WalkSpeeds.diagonalspeed, EasingTime)
		elseif W and D then
			Humanoid.WalkSpeed = lerp(Humanoid.WalkSpeed, WalkSpeeds.diagonalspeed, EasingTime)
		elseif S then
			Humanoid.WalkSpeed = lerp(Humanoid.WalkSpeed, WalkSpeeds.backwardsspeed, EasingTime)
		elseif S and A then
			Humanoid.WalkSpeed = lerp(Humanoid.WalkSpeed, WalkSpeeds.backwardsspeed - (WalkSpeeds.diagonalspeed - WalkSpeeds.backwardsspeed), EasingTime)
		elseif S and D then
			Humanoid.WalkSpeed = lerp(Humanoid.WalkSpeed, WalkSpeeds.backwardsspeed - (WalkSpeeds.diagonalspeed - WalkSpeeds.backwardsspeed), EasingTime)
		elseif D then
			Humanoid.WalkSpeed = lerp(Humanoid.WalkSpeed, WalkSpeeds.sidewaysspeed, EasingTime)
		elseif A then
			Humanoid.WalkSpeed = lerp(Humanoid.WalkSpeed, WalkSpeeds.sidewaysspeed, EasingTime)
		end    

		if LShift and W then
			FieldOfView = lerp(FieldOfView, WalkSpeeds.runningFOV, EasingTime)
			Humanoid.WalkSpeed = lerp(Humanoid.WalkSpeed, Humanoid.WalkSpeed + (WalkSpeeds.runningspeed - Humanoid.WalkSpeed), EasingTime)
		end
	end
end)

maybe constantly force their character to that angle? it would probably cause lag though

Yeah, I’ve been staring at this for hours lol can’t seem to come up with a solution.

or you could anchor the player’s HRP then move them… not sure how (im dumb)

HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position) * CFrame.Angles(0, math.rad(AngleY), 0)

Add a check to this line to ensure you are wallclimbing before turning the player.