wait(.1)local t=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local o=game.Workspace.CurrentCamera local n=game.Players.LocalPlayer local P=n.Character local b=P.Head local d=P.Torso local M=P.HumanoidRootPart local h=M.RootJoint local I=d.Neck o.FieldOfView=90 o.CameraType="\083\099\114\105\112\116\097\098\108\101"t.MouseBehavior=Enum.MouseBehavior.LockCenter local E=Vector3.new local u=CFrame.new local H=(u()).components local x=(u()).inverse local W=CFrame.fromAxisAngle local X,m=math.atan,math.atan2 local N=math.acos local function Y(t)local o=t.z return o*o<.99999 and(E(t.y,-t.x,0)).unit*N(-o)or E()end local function U(t,o,n)local P=t-t.p local b=(x(P)*o).unit local d=b.z return d*d<.99999 and P*W(E(b.y,-b.x,0),N(-d)*(n or 1))or P end local function z(t,o)local n=t.unit local P=n.z return P*P<.99999 and W(E(n.y,-n.x,0),N(-P)*(o or 1))or u()end local function C(t,o,n)local P=(x(t)*o).unit local b=P.z return b*b<.99999 and t*W(E(P.y,-P.x,0),N(-b)*(n or 1))or t end local s=.005 local l=Vector3.new(0,0,0)local function e(t)local o,n=t.x,t.z return X(t.y/(o*o+n*n)^.5),-m(o,-n)end local function w(t)local o=t.z return m(t.y,-o),-m(t.x,-o)end local function K(t)if t.UserInputType==Enum.UserInputType.MouseMovement then local o,n=t.Delta.x*s,t.Delta.y*s local P=o*o+n*n if P>0 then l=(U(M.CFrame,l)*W(E(-n,-o,0),P^.5)).lookVector end local b=M.CFrame-M.Position local d=b:inverse()*l local h,I=w(d)if h<-1.4391666666667 then local t,o,n,P=d.y,d.z,math.cos(-1.4391666666667-h),-math.sin(-1.4391666666667-h)o,t=o*n-t*P,o*P+t*n l=b*E(d.x<0 and-((1-t*t)-o*o)^.5 or((1-t*t)-o*o)^.5,t,o)elseif h>1.4391666666667 then local t,o,n,P=d.y,d.z,math.cos(1.4391666666667-h),-math.sin(1.4391666666667-h)o,t=o*n-t*P,o*P+t*n l=b*E(d.x<0 and-((1-t*t)-o*o)^.5 or((1-t*t)-o*o)^.5,t,o)end end end local D=n:GetMouse()local j=-0.5 D.KeyDown:connect(function(t)if t=="\101"then j=-0.5 elseif t=="\113"then j=-0.5 end end)t.InputChanged:connect(K)I.C1=u()local O local v=1.0471966666667 local G=0 local function R()o.CameraType="\083\099\114\105\112\116\097\098\108\101"local t,n=l.x,l.z local b,d=M.Velocity.x,M.Velocity.z if b*b+d*d>4 and t*b+n*d<(-0.5*(t*t+n*n)^.5)*(b*b+d*d)^.5 then v=math.min(v*.9,math.abs(G*.9))else v=v*.1+.942477 end local h,H=e((M.CFrame-M.Position):inverse()*l)if H>v then M.CFrame=M.CFrame*CFrame.Angles(0,H-v,0)elseif H<-v then M.CFrame=M.CFrame*CFrame.Angles(0,H+v,0)end O,G=e((M.CFrame-M.Position):inverse()*l)local x=z((M.CFrame-M.Position):inverse()*l,1)I.C0=(CFrame.new(0,1,0)*x)*CFrame.new(0,.5,0)local W=C(M.CFrame*u(0,1,0),M.CFrame*E(0,1,0)+l)*CFrame.new(0,.825,0)if j==8 then local t,n=Workspace:findPartOnRay(Ray.new(W.p,W.lookVector*-8),P)o.CoordinateFrame=W*CFrame.new(0,0,(n-W.p).magnitude)else o.CoordinateFrame=W*CFrame.new(0,0,j)end end;(game:GetService("\082\117\110\083\101\114\118\105\099\101")).RenderStepped:connect(R)
-- DONT EDIT NOTHING IN THE SCRIPT IF YOU DONT KNOW WHAT YOU DOING!
-- This script is for iiFireGamingOfDoom.
wait(0.1)
local InputService = game:GetService("UserInputService")
local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Head = Character.Head
local Torso = Character.Torso
local RootPart = Character.HumanoidRootPart
local RootJoint = RootPart.RootJoint
local Neck = Torso.Neck
Camera.FieldOfView = 90
Camera.CameraType = "Scriptable"
InputService.MouseBehavior = Enum.MouseBehavior.LockCenter

local v3 = Vector3.new
local cf = CFrame.new
local components = cf().components
local inverse = cf().inverse
local fromAxisAngle = CFrame.fromAxisAngle
local atan, atan2 = math.atan, math.atan2
local acos = math.acos

local function toAxisAngleFromVector(v)
	local z = v.z
	return z * z < 0.99999 and v3(v.y, -v.x, 0).unit * acos(-z) or v3()
end

local function AxisAngleLookOrientation(c, v, t) --CFrame,Vector,Tween
	local c = c - c.p
	local rv = (inverse(c) * v).unit
	local rz = rv.z
	return rz * rz < 0.99999 and c * fromAxisAngle(v3(rv.y, -rv.x, 0), acos(-rz) * (t or 1)) or c
end

local function AxisAngleLookNew(v, t) --CFrame,Vector,Tween
	local rv = v.unit
	local rz = rv.z
	return rz * rz < 0.99999 and fromAxisAngle(v3(rv.y, -rv.x, 0), acos(-rz) * (t or 1)) or cf()
end

local function AxisAngleLook(c, v, t) --CFrame,Vector,Tween
	local rv = (inverse(c) * v).unit
	local rz = rv.z
	return rz * rz < 0.99999 and c * fromAxisAngle(v3(rv.y, -rv.x, 0), acos(-rz) * (t or 1)) or c
end

local Sensitivity = 0.005

local CameraDirection = Vector3.new(0, 0, 0)

local function EulerAnglesYX(l)
	local x, z = l.x, l.z
	return atan(l.y / (x * x + z * z) ^ 0.5), -atan2(x, -z)
end

local function AnglesXY(l)
	local z = l.z
	return atan2(l.y, -z), -atan2(l.x, -z)
end

local function MouseMoved(Input)
	if Input.UserInputType == Enum.UserInputType.MouseMovement then
		local dx, dy = Input.Delta.x * Sensitivity, Input.Delta.y * Sensitivity
		local m2 = dx * dx + dy * dy
		if m2 > 0 then
			CameraDirection = (AxisAngleLookOrientation(RootPart.CFrame, CameraDirection) * fromAxisAngle(
				v3(-dy, -dx, 0),
				m2 ^ 0.5
			)).lookVector
		end
		local RootOrientation = RootPart.CFrame - RootPart.Position
		local RelativeDirection = RootOrientation:inverse() * CameraDirection
		local AngX, AngY = AnglesXY(RelativeDirection) --RootOrientation:inverse()*
		if AngX < -1.57 * 11 / 12 then
			local y, z, c, s =
				RelativeDirection.y,
				RelativeDirection.z,
				math.cos(-1.57 * 11 / 12 - AngX),
				-math.sin(-1.57 * 11 / 12 - AngX)
			z, y = z * c - y * s, z * s + y * c
			CameraDirection = RootOrientation
				* v3(RelativeDirection.x < 0 and -(1 - y * y - z * z) ^ 0.5 or (1 - y * y - z * z) ^ 0.5, y, z)
		elseif AngX > 1.57 * 11 / 12 then
			local y, z, c, s =
				RelativeDirection.y,
				RelativeDirection.z,
				math.cos(1.57 * 11 / 12 - AngX),
				-math.sin(1.57 * 11 / 12 - AngX)
			z, y = z * c - y * s, z * s + y * c
			CameraDirection = RootOrientation
				* v3(RelativeDirection.x < 0 and -(1 - y * y - z * z) ^ 0.5 or (1 - y * y - z * z) ^ 0.5, y, z)
		end
	end
end

local Mouse = Player:GetMouse()

local Zoom = -0.5

Mouse.KeyDown:connect(function(k)
	if k == "e" then
		Zoom = -0.5
	elseif k == "q" then
		Zoom = -0.5
	end
end)

InputService.InputChanged:connect(MouseMoved)

Neck.C1 = cf()

local _
local DirectionBound = 3.14159 / 3
local CurrentAngY = 0

local function CameraUpdate()
	Camera.CameraType = "Scriptable"
	local cx, cz = CameraDirection.x, CameraDirection.z
	local rvx, rvz = RootPart.Velocity.x, RootPart.Velocity.z
	if
		rvx * rvx + rvz * rvz > 4 and cx * rvx + cz * rvz < -0.5 * (cx * cx + cz * cz) ^ 0.5 * (rvx * rvx + rvz * rvz) ^ 0.5
	then
		DirectionBound = math.min(DirectionBound * 0.9, math.abs(CurrentAngY * 0.9))
	else
		DirectionBound = DirectionBound * 0.1 + 3.14159 / 3 * 0.9
	end
	local AngX, AngY = EulerAnglesYX((RootPart.CFrame - RootPart.Position):inverse() * CameraDirection)
	if AngY > DirectionBound then
		RootPart.CFrame = RootPart.CFrame * CFrame.Angles(0, AngY - DirectionBound, 0)
	elseif AngY < -DirectionBound then
		RootPart.CFrame = RootPart.CFrame * CFrame.Angles(0, AngY + DirectionBound, 0)
	end
	_, CurrentAngY = EulerAnglesYX((RootPart.CFrame - RootPart.Position):inverse() * CameraDirection)
	local CameraOrientation = AxisAngleLookNew((RootPart.CFrame - RootPart.Position):inverse() * CameraDirection, 1)
	Neck.C0 = CFrame.new(0, 1, 0) * CameraOrientation * CFrame.new(0, 0.5, 0)
	local PreCam = AxisAngleLook(RootPart.CFrame * cf(0, 1, 0), RootPart.CFrame * v3(0, 1, 0) + CameraDirection)
		* CFrame.new(0, 0.825, 0)
	if Zoom == 8 then
		local Part, Position = Workspace:findPartOnRay(Ray.new(PreCam.p, PreCam.lookVector * -8), Character)
		Camera.CoordinateFrame = PreCam * CFrame.new(0, 0, (Position - PreCam.p).magnitude)
	else
		Camera.CoordinateFrame = PreCam * CFrame.new(0, 0, Zoom)
	end
end

game:GetService("RunService").RenderStepped:connect(CameraUpdate)
