runService.RenderStepped:connect(function()if running then updatechar()CamPos=CamPos+(TargetCamPos-CamPos)*.28 AngleX=AngleX+(TargetAngleX-AngleX)*.35 local M=TargetAngleY-AngleY M=math.abs(M)>180 and M-(M/math.abs(M))*360 or M AngleY=(AngleY+M*.35)%360 cam.CameraType=Enum.CameraType.Scriptable cam.CoordinateFrame=((CFrame.new(head.Position)*CFrame.Angles(0,math.rad(AngleY),0))*CFrame.Angles(math.rad(AngleX),0,0))*HeadOffset humanoidpart.CFrame=CFrame.new(humanoidpart.Position)*CFrame.Angles(0,math.rad(AngleY),0)else(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).MouseBehavior=Enum.MouseBehavior.Default end if(cam.Focus.p-cam.CoordinateFrame.p).magnitude<1 then running=false else running=true if freemouse==true then(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).MouseBehavior=Enum.MouseBehavior.Default else(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).MouseBehavior=Enum.MouseBehavior.LockCenter end end if not CanToggleMouse.allowed then freemouse=false end cam.FieldOfView=FieldOfView if walkspeeds.enabled then if w and s then return end if w and not lshift then FieldOfView=lerp(FieldOfView,defFOV,easingtime)human.WalkSpeed=lerp(human.WalkSpeed,walkspeeds.walkingspeed,easingtime)elseif w and a then human.WalkSpeed=lerp(human.WalkSpeed,walkspeeds.diagonalspeed,easingtime)elseif w and d then human.WalkSpeed=lerp(human.WalkSpeed,walkspeeds.diagonalspeed,easingtime)elseif s then human.WalkSpeed=lerp(human.WalkSpeed,walkspeeds.backwardsspeed,easingtime)elseif s and a then human.WalkSpeed=lerp(human.WalkSpeed,walkspeeds.backwardsspeed-(walkspeeds.diagonalspeed-walkspeeds.backwardsspeed),easingtime)elseif s and d then human.WalkSpeed=lerp(human.WalkSpeed,walkspeeds.backwardsspeed-(walkspeeds.diagonalspeed-walkspeeds.backwardsspeed),easingtime)elseif d then human.WalkSpeed=lerp(human.WalkSpeed,walkspeeds.sidewaysspeed,easingtime)elseif a then human.WalkSpeed=lerp(human.WalkSpeed,walkspeeds.sidewaysspeed,easingtime)end if lshift and w then FieldOfView=lerp(FieldOfView,walkspeeds.runningFOV,easingtime)human.WalkSpeed=lerp(human.WalkSpeed,human.WalkSpeed+(walkspeeds.runningspeed-human.WalkSpeed),easingtime)end end end)


runService.RenderStepped:connect(function()
	 
	if running then
		updatechar()
		
		CamPos = CamPos + (TargetCamPos - CamPos) *0.28 
		AngleX = AngleX + (TargetAngleX - AngleX) *0.35 
		local dist = TargetAngleY - AngleY 
		dist = math.abs(dist) > 180 and dist - (dist / math.abs(dist)) * 360 or dist 
		AngleY = (AngleY + dist *0.35) %360
		cam.CameraType = Enum.CameraType.Scriptable
		
		cam.CoordinateFrame = CFrame.new(head.Position) 
		* CFrame.Angles(0,math.rad(AngleY),0) 
		* CFrame.Angles(math.rad(AngleX),0,0)
		* HeadOffset -- offset
		
		humanoidpart.CFrame=CFrame.new(humanoidpart.Position)*CFrame.Angles(0,math.rad(AngleY),0)
		else game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default
	end

	if (cam.Focus.p-cam.CoordinateFrame.p).magnitude < 1 then
		running = false
	else
		running = true
		if freemouse == true then
			game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default
		else
			game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
		end
	end
	
	if not CanToggleMouse.allowed then
		freemouse = false
	end
	
	cam.FieldOfView = FieldOfView
	
	if walkspeeds.enabled then
		if w and s then return end
		
		if w and not lshift then
			FieldOfView = lerp(FieldOfView, defFOV,easingtime)
			human.WalkSpeed = lerp(human.WalkSpeed,walkspeeds.walkingspeed,easingtime)
		elseif w and a then
			human.WalkSpeed = lerp(human.WalkSpeed,walkspeeds.diagonalspeed,easingtime)
		elseif w and d then
			human.WalkSpeed = lerp(human.WalkSpeed,walkspeeds.diagonalspeed,easingtime)
		elseif s then
			human.WalkSpeed = lerp(human.WalkSpeed,walkspeeds.backwardsspeed,easingtime)
		elseif s and a then
			human.WalkSpeed = lerp(human.WalkSpeed,walkspeeds.backwardsspeed - (walkspeeds.diagonalspeed - walkspeeds.backwardsspeed),easingtime)
		elseif s and d then
			human.WalkSpeed = lerp(human.WalkSpeed,walkspeeds.backwardsspeed - (walkspeeds.diagonalspeed - walkspeeds.backwardsspeed),easingtime)
		elseif d then
			human.WalkSpeed = lerp(human.WalkSpeed,walkspeeds.sidewaysspeed,easingtime)
		elseif a then
			human.WalkSpeed = lerp(human.WalkSpeed,walkspeeds.sidewaysspeed,easingtime)
		end	
		
		if lshift and w then
			FieldOfView = lerp(FieldOfView, walkspeeds.runningFOV,easingtime)
			human.WalkSpeed = lerp(human.WalkSpeed,human.WalkSpeed + (walkspeeds.runningspeed - human.WalkSpeed),easingtime)
		end
	end
		
end)
