--- Add sounds when interacting with a gui element



return function(element, interactType, interactSoundId, interactSoundVolume, enableRandomPitch)
	--- Variables
	interactType = string.lower(interactType)
	interactSoundVolume = interactSoundVolume or 0.15
	enableRandomPitch = enableRandomPitch or false
	--
	local events = {}
	
	--- Events
	if interactType == "mousedown" then
		--- Mouse down
		events[#events + 1] = element.MouseButton1Down:Connect(function()
			_L.Audio.Play(interactSoundId, script, (enableRandomPitch and math.random(95, 105) / 100 or 1), interactSoundVolume * 2)
		end)
		
	elseif interactType == "mouseup" then
		--- Mouse up
		events[#events + 1] = element.MouseButton1Up:Connect(function()
			_L.Audio.Play(interactSoundId, script, (enableRandomPitch and math.random(95, 105) / 100 or 1), interactSoundVolume * 2)
		end)
		
	elseif interactType == "mouseenter" then
		--- Mouse hover over
		events[#events + 1] = element.MouseEnter:Connect(function()
			_L.Audio.Play(interactSoundId, script, (enableRandomPitch and math.random(95, 105) / 100 or 1), interactSoundVolume)
		end)

	elseif interactType == "mouseleave" then
		--- Mouse hover leave
		events[#events + 1] = element.MouseLeave:Connect(function()
			_L.Audio.Play(interactSoundId, script, (enableRandomPitch and math.random(95, 105) / 100 or 1), interactSoundVolume)
		end)
	
	elseif interactType == "mouseclick" then
		--- Mouse click
		events[#events + 1] = element.MouseButton1Click:Connect(function()
			_L.Audio.Play(interactSoundId, script, (enableRandomPitch and math.random(95, 105) / 100 or 1), interactSoundVolume)
		end)
	end
	
	--- Return function to cancel this behavior
	return function()
		for _, event in ipairs(events) do
			event:disconnect()
		end
		events = nil
	end
end
