--------------------[ MOUSE FUNCTIONS ]-----------------------------------------------


function onMB1Down()
	MB1Down = true
	firstShot = true
	if fireFunction then
		fireFunction()
	end
end

function onMB1Up()
	MB1Down = false
	lowerSpread()
end

function onMB2Down()
	if S.aimSettings.holdToADS then
		if (not AimingIn) and (not Aimed) then
			AimingIn = true
			aimGun()
			AimingIn = false
		end
	else
		if Aimed then
			unAimGun()
		else
			aimGun()
		end
	end
end

function onMB2Up()
	if S.aimSettings.holdToADS then
		if (not AimingOut) and Aimed then
			AimingOut = true
			unAimGun()
			AimingOut = false
		end
	end
end

function onScrollUp()
	local newAimSensitivity = aimSensitivity + S.sensitivitySettings.Increment
	aimSensitivity = (
		newAimSensitivity < S.sensitivitySettings.Min and S.sensitivitySettings.Min or
		newAimSensitivity > S.sensitivitySettings.Max and S.sensitivitySettings.Max or
		newAimSensitivity
	)
	mouseSensitivity = (Aimed and aimSensitivity or mouseSensitivity)
	
	Sens.Text = "S: "..aimSensitivity
	if mainGUI:IsDescendantOf(game) then
		Sens.Visible = true
		local t0 = tick()
		lastSensUpdate = t0
		
		wait(0.3)
		
		if lastSensUpdate <= t0 then
			Sens.Visible = true
		end
	end
end

function onScrollDown()
	local newAimSensitivity = aimSensitivity - S.sensitivitySettings.Increment
	aimSensitivity = (
		newAimSensitivity < S.sensitivitySettings.Min and S.sensitivitySettings.Min or
		newAimSensitivity > S.sensitivitySettings.Max and S.sensitivitySettings.Max or
		newAimSensitivity
	)
	mouseSensitivity = (Aimed and aimSensitivity or mouseSensitivity)
	
	Sens.Text = "S: "..aimSensitivity
	if mainGUI:IsDescendantOf(game) then
		Sens.Visible = true
		local t0 = tick()
		lastSensUpdate = t0
		
		wait(0.3)
		
		if lastSensUpdate <= t0 then
			Sens.Visible = true
		end
	end
end
