--// ------------------------------- //--
--// Don't edit anything below here! //--
--// ------------------------------- //--


local camera = game.Workspace.CurrentCamera
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local Z = 0
local damping = (character.Humanoid.WalkSpeed / 2) * GENERAL_DAMPING
local PI = 3.1415926
local tick = PI / 2
local running = false
local strafing = false

humanoid.Strafing:Connect(function(bool)
	strafing = bool
end)

humanoid.Jumping:Connect(function()
	running = false
end)

humanoid.Swimming:Connect(function()
	running = false
end)

humanoid.Running:Connect(function(speed)
	if speed > 0.1 then
		running = true
	else
		running = false
	end
end)

local function mix(par1, par2, factor)
	return par2 + (par1 - par2) * factor
end

while true do
	game:GetService("RunService").RenderStepped:Wait()
	
	fps = (camera.CFrame.p - character.Head.Position).Magnitude
	
	if fps < 0.52 then
		Z = 1
	else
		Z = 0
	end
	
	if running == true and strafing == false then
		tick = tick + humanoid.WalkSpeed / 92
	else
		if tick > 0 and tick < PI / 2 then
			tick = mix(tick, PI / 2, 0.9)
		end
		if tick > PI / 2 and tick < PI then
			tick = mix(tick, PI / 2, 0.9)
		end
		if tick > PI and tick < PI * 1.5 then
			tick = mix(tick, PI * 1.5, 0.9)
		end
		if tick > PI * 1.5 and tick < PI * 2 then
			tick = mix(tick, PI * 1.5, 0.9)
		end
	end
	
	if tick >= PI * 2 then
		tick = 0
	end	
	
	camera.CFrame = camera.CFrame * 
		CFrame.new(math.cos(tick) / damping * OFFSET_DAMPING, math.sin(tick * 2) / (damping * 2 * OFFSET_DAMPING), Z) * 
		CFrame.Angles(0, 0, math.sin(tick - PI * 1.5) / (damping * 15 * TILT_DAMPING)) --Set camera CFrame
end
