Smooth R15 and R6 camera system!

This resource is about a fps cam system I made that works for both r6 and R15. You need to copy the script and past it to your own game

here’s footage of it in action:

You can also add a head movement script since this doesn’t come with that

here’s the cam system script


function GetSubjectPosition()
	local camera = workspace.CurrentCamera
	local subject = camera.CameraSubject

	if subject and subject:IsA("Humanoid") and subject.Health > 0 then
		local character = subject.Parent
		local head = character and character:FindFirstChild("Head")

		if head and head:IsA("BasePart") then
			local cf = head.CFrame
			local offset = cf * CFrame.new(0, head.Size.Y / 3, -0.5)

			return offset.Position, cf.LookVector
		end
	end
end

function IsInFirstPerson()
	local camera = workspace.CurrentCamera

	if camera then
		if camera.CameraType.Name ~= "Custom" then
			return false
		end

		local focus = camera.Focus.Position
		local origin = camera.CFrame.Position

		return (focus - origin).Magnitude <= 1-- and camera.CameraSubject.Parent:FindFirstChild("Head").LocalTransparencyModifier > 0.6700000166893005
	end

	return false
end

local camera = workspace.CurrentCamera

local XZ_VECTOR3 = Vector3.new(1, 0, 1)

InvalidRotationStates =
	{
		Swimming = true; 
		Climbing = false;
		Dead = true;
		Seated = true;
	};

game:GetService("RunService"):BindToRenderStep("FpsCamera", 1000, function(delta)
	if IsInFirstPerson() then
		local subject = camera.CameraSubject
		local rootPart = subject.RootPart

		if rootPart then
			local state = subject:GetState()
			local canRotate = true

			if InvalidRotationStates[state.Name] then
				canRotate = false
			end

			if subject.Sit and subject.SeatPart then
				local root = rootPart:GetRootPart()

				if root ~= rootPart then
					canRotate = false
				end
			end

			if canRotate then
				local pos = rootPart.Position

				local look = camera.CFrame.LookVector
				look = (look * XZ_VECTOR3).Unit

				local cf = CFrame.new(pos, pos + look)
				rootPart.CFrame = cf
			end
		end

		local cf = camera.CFrame
		local headPos, headLook = GetSubjectPosition()

		if headPos then
			local offset = (headPos - cf.Position)
			cf += offset

			camera.CFrame = cf
			camera.Focus += offset
		end
	end

	if game.Players.LocalPlayer.Character then
		for _, part in ipairs(game.Players.LocalPlayer.Character:GetChildren()) do 
			if part:IsA("BasePart") and part.Name ~= "Head" then 
				part.LocalTransparencyModifier = 0 
			end 
		end
	end
end)

Fix Number 1:
I fixed some stuff as said in the comments, and for anyone asking this is 100% original code I just stripped this from my complicated and messy cam system in one of my games

Fix Number 2:
I made it so LockFirstPerson isn’t required so you can zoom out as you like

IMPORTANT NOTE: Make sure you made StarterPlayer.CameraMode to LockFirstPerson (optional) and put the script in a LocalScript in StarterPlayerScripts

if there are any problems or questions reply below!

16 Likes

Xan_TheDragon is your inspiration, I’d assume.

EDIT: You forgot to replace “workspace.BlueD_NF” with “game.Players.LocalPlayer.Character”.

1 Like

Oh sorry I’ll fix that rn I was just making this quickly and didn’t realize since my original code was a mess, and no I made this myself

1 Like