Can't Rotate Without Holding Right Click + Stuttering

I’m currently doing my first attempt at a custom camera controller.

It works as intended except for the fact that I can only turn when holding down the right click button. When walking backwards there also appears to be stuttering / glitching.
robloxapp-20200714-1929478.wmv (1.9 MB)

I’ve been looking for a couple hours through other people’s custom character controllers to figure this out and can’t seem to find one with an issue with turning without holding right click.

Thank you very much for any help, below is all the code at this point which is in a LocalScript inside StarterPlayerScripts.

local UserInputService = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local player = game:GetService("Players").LocalPlayer
game:GetService("RunService").RenderStepped:connect(function()
	if player.Character then
		local root = player.Character.HumanoidRootPart
		if root then
			player.Character.Humanoid.CameraOffset = Vector3.new(2,1,0)
			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
			root.CFrame = CFrame.new(root.CFrame.p,root.CFrame.p + Vector3.new(camera.CFrame.lookVector.X ,0 ,camera.CFrame.lookVector.Z))
		end
	end
end)

Update: This has now rendered my ability to turn the camera in studio mode non existent even after ending a test play.

I’m not quite sure what you want here, but I think you’re wanting the character to face the same direction as the camera. If so, then here’s a good post from when I helped another person with the same thing. Though, remember to set Humanoid.AutoRotate to false.

Humanoid.CameraOffset is also something which you don’t need to set more than once for your specific case, so I’d leave it outside of the .RenderStepped function.

This is quite finicky, but :connect (lower-case c) is deprecated whereas :Connect is not.

1 Like