--------------------[ CAMERA STEADYING FUNCTIONS ]------------------------------------


function SteadyCamera()
	Gui_Clone.Scope.Steady.Text = "Steadying..."
	Gui_Clone.Scope.Steady.TextColor3 = Color3.new(1, 1, 0)
	CameraSteady = true
	local OriginalSway = CameraSway
	for X = 0, 90, 1.5 / 0.6 do
		if (not Run_Key_Pressed) then break end
		local Alpha = SIN(RAD(X))
		CameraSway = NumLerp(OriginalSway, 0, Alpha)
		RS:wait()
	end
	while Run_Key_Pressed and Aimed do
		if CurrentSteadyTime > 0 then
			local NewSteadyTime = CurrentSteadyTime - 1
			CurrentSteadyTime = (NewSteadyTime < 0 and 0 or NewSteadyTime)
			CameraSway = 0
		elseif CurrentSteadyTime == 0 then
			break
		end
		RS:wait()
	end
	CameraSteady = false
	spawn(function()
		for X = 0, 90, 1.5 / 0.2 do
			local Alpha = math.log10(X) / math.log10(90)
			CameraSway = NumLerp(0, 3, Alpha)
			RS:wait()
		end
		for X = 0, 90, 1.5 / S.ScopeSteadyTime do
			if CameraSteady then break end
			local Alpha = SIN(RAD(X))
			CameraSway = NumLerp(3, 1, Alpha)
			RS:wait()
		end
	end)
	RetakeBreath()
end

function RetakeBreath()
	local Steady = Gui_Clone.Scope.Steady
	Steady.Text = "Re-taking Breath"
	Steady.TextColor3 = Color3.new(1, 0, 0)
	TakingBreath = true
	while TakingBreath do
		if CurrentSteadyTime < MaxSteadyTime then
			local NewSteadyTime = CurrentSteadyTime + (S.ScopeSteadyTime / S.SteadyCooldownTime)
			CurrentSteadyTime = (NewSteadyTime > MaxSteadyTime and MaxSteadyTime or NewSteadyTime)
		elseif CurrentSteadyTime >= MaxSteadyTime then
			break
		end
		RS:wait()
	end
	if TakingBreath then
		Steady.Text = "Hold "..ConvertKey(S.ScopeSteadyKey).." to Steady"
		Steady.TextColor3 = Color3.new(1, 1, 0)
		TakingBreath = false
	end
end
