Is there open-source first person camera controller

i am making a game with custom first person camera controller but my code have jitters
i want to have fully control over my camera thats why i want first person camera controller

i tried using mouse.move but nothing changed

local runService = game:GetService("RunService")
local userInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")

local camera = workspace.CurrentCamera

local cp = Instance.new("Part", workspace)
cp.Anchored = true
cp.CanCollide = false
cp.Locked = true
cp.Size = Vector3.new(1,1,1)
cp.Transparency = 1
cp.Name = "custom_camera"

local player = game.Players.LocalPlayer
local character = player.Character
local mouse = player:GetMouse()

local FREEZE_ACTION = "freezeMovement"

local isb2d = false

function b2d()
	isb2d = true
end

function b2u()
	isb2d = false
end

cp.CFrame = camera.CFrame
cp.Orientation = Vector3.new(math.clamp(cp.Orientation.X, -80, 80), cp.Orientation.Y, 0)

function update()
	userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
	
	camera.CameraType = Enum.CameraType.Scriptable
	
	local delta = userInputService:GetMouseDelta()
	print(cp.Orientation.X)
	camera.CFrame = cp.CFrame * CFrame.Angles(-math.rad(delta.y) / 1, -math.rad(delta.x) / 1, 0)
	cp.CFrame = camera.CFrame
	cp.Orientation = Vector3.new(math.clamp(cp.Orientation.X, -80, 80), cp.Orientation.Y, 0)
end

ContextActionService:BindAction(
	FREEZE_ACTION,
	function() return Enum.ContextActionResult.Sink end,
	false,
	unpack(Enum.PlayerActions:GetEnumItems())
)

mouse.Move:Connect(update)
mouse.Button2Down:Connect(b2d)
mouse.Button2Up:Connect(b2u)

is there a open-source first person camera controller?
thanks :slightly_smiling_face:

1 Like

If you want to players to be locked in first person then you can just go to StarterPlayer and change this option to “LockFirstPerson”. image

no i want control over movement speed and everything not just first person camera