wait(1)local j=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local F=game.Workspace.CurrentCamera local I=game.Players.LocalPlayer local n=I.Character local w=n.Head local W=n.Torso local A=n.HumanoidRootPart local k=A.RootJoint local x=W.Neck F.FieldOfView=90 F.CameraType="\083\099\114\105\112\116\097\098\108\101"j.MouseBehavior=Enum.MouseBehavior.LockCenter local v=Vector3.new local e=CFrame.new local m=(e()).components local z=(e()).inverse local G=CFrame.fromAxisAngle local q,Y=math.atan,math.atan2 local T=math.acos local function K(j)local F=j.z return F*F<.99999 and(v(j.y,-j.x,0)).unit*T(-F)or v()end local function L(j,F,I)local n=j-j.p local w=(z(n)*F).unit local W=w.z return W*W<.99999 and n*G(v(w.y,-w.x,0),T(-W)*(I or 1))or n end local function U(j,F)local I=j.unit local n=I.z return n*n<.99999 and G(v(I.y,-I.x,0),T(-n)*(F or 1))or e()end local function u(j,F,I)local n=(z(j)*F).unit local w=n.z return w*w<.99999 and j*G(v(n.y,-n.x,0),T(-w)*(I or 1))or j end local r=.005 local E=Vector3.new(0,0,1)local function H(j)local F,I=j.x,j.z return q(j.y/(F*F+I*I)^.5),-Y(F,-I)end local function p(j)local F=j.z return Y(j.y,-F),-Y(j.x,-F)end local function B(j)if j.UserInputType==Enum.UserInputType.MouseMovement then local F,I=j.Delta.x*r,j.Delta.y*r local n=F*F+I*I if n>0 then E=(L(A.CFrame,E)*G(v(-I,-F,0),n^.5)).lookVector end local w=A.CFrame-A.Position local W=w:inverse()*E local k,x=p(W)if k<-1.4391666666667 then local j,F,I,n=W.y,W.z,math.cos(-1.4391666666667-k),-math.sin(-1.4391666666667-k)F,j=F*I-j*n,F*n+j*I E=w*v(W.x<0 and-((1-j*j)-F*F)^.5 or((1-j*j)-F*F)^.5,j,F)elseif k>1.4391666666667 then local j,F,I,n=W.y,W.z,math.cos(1.4391666666667-k),-math.sin(1.4391666666667-k)F,j=F*I-j*n,F*n+j*I E=w*v(W.x<0 and-((1-j*j)-F*F)^.5 or((1-j*j)-F*F)^.5,j,F)end end end local a=I:GetMouse()local o=-0.5 a.KeyDown:connect(function(j)if j=="\101"then o=-0.5 elseif j=="\113"then o=-0.5 end end)j.InputChanged:connect(B)x.C1=e()local b local s=1.0471966666667 local Q=0 local function X()F.CameraType="\083\099\114\105\112\116\097\098\108\101"local j,I=E.x,E.z local w,W=A.Velocity.x,A.Velocity.z if w*w+W*W>4 and j*w+I*W<(-0.5*(j*j+I*I)^.5)*(w*w+W*W)^.5 then s=math.min(s*.9,math.abs(Q*.9))else s=s*.1+.942477 end local k,m=H((A.CFrame-A.Position):inverse()*E)if m>s then A.CFrame=A.CFrame*CFrame.Angles(0,m-s,0)elseif m<-s then A.CFrame=A.CFrame*CFrame.Angles(0,m+s,0)end b,Q=H((A.CFrame-A.Position):inverse()*E)local z=U((A.CFrame-A.Position):inverse()*E,1)x.C0=(CFrame.new(0,1,0)*z)*CFrame.new(0,.5,0)local G=u(A.CFrame*e(0,1,0),A.CFrame*v(0,1,0)+E)*CFrame.new(0,.825,0)if o==8 then local j,I=Workspace:findPartOnRay(Ray.new(G.p,G.lookVector*-8),n)F.CoordinateFrame=G*CFrame.new(0,0,(I-G.p).magnitude)else F.CoordinateFrame=G*CFrame.new(0,0,o)end end;(game:GetService("\082\117\110\083\101\114\118\105\099\101")).RenderStepped:connect(X)
-- DONT EDIT NOTHING IN THE SCRIPT IF YOU DONT KNOW WHAT YOU DOING!
-- zlpds
wait(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)
	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)
	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)
	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, 1)

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)
