Issues with Dash mechanic Directions

Hi guys,

I have recently added a Dashing mechanic to my game, however I am starting notice issues with the direction that player dashes in.

Basically the mechanic works off of double tapping (WASD) within a certain amount of time, and the player dashes in the direction of the key they pressed (if double tapped W then dash forward, if A then dash left, ect.)

However, I also have a secondary mechanic where the player can hold (WASD) and press X, and they then dash in the direction of the key they pressed. (If W and X then dash forward, if A and X then dash left).

Whenever the Player uses the mechanic with X, the dash does not work correctly. If they use A and X they are supposed to dash left, but instead they go back and left. Here’s an example:

https://gyazo.com/f37f6a52224b3fa1b2d6ee7e7e878254
(The first dash is double tapped A, the other 2 are A and X.)

^ This happens with all of (WASD) and X dashes except for the forward dash. As you can see in this GIF; A+X goes back and left, S+X goes back and slightly left, D+X goes back and right:
https://gyazo.com/ccd5d6962621503bb791fe3674c73545

I am not sure why this happening as I am using the same dash code for each, which can be seen here.
(Left Dash for example)

Summary
UIS.InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.A then
		local now = tick()
		local difference = (now - LastTime3)

		if difference <= DoubleTapTime and not DB then
			DB = true
			HRP.Velocity = HRP.CFrame.rightVector * -200
			wait(CoolDown)
			DB = false
		end
		LastTime3 = tick()
	elseif UIS:IsKeyDown(Enum.KeyCode.A) and input.KeyCode == Enum.KeyCode.X then
		if not DB then
			DB = true
			HRP.Velocity = HRP.CFrame.rightVector * -200
			wait(CoolDown)
			DB = false
		end
	end
end)

The only difference with the double tap Dash and the (WASD) + X Dash is that the X Dash uses UIS:IsKeyDown(Enum.KeyCode.A) and input.KeyCode == Enum.KeyCode.X then instead of just using if input.KeyCode == Enum.KeyCode.A then. So I am not sure if they may be the issue?

Here is the entire dash mechanic code:

Summary
local Tapped = false
local DoubleTapTime = 0.2
local CoolDown = 1.5

local LastTime = tick()
local LastTime2 = tick()
local LastTime3 = tick()
local LastTime4 = tick()

local DB = false


--FORWARD DASH												
UIS.InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.W then
		local now = tick()
		local difference = (now - LastTime)

		if difference <= DoubleTapTime and not DB then 
			DB = true
			HRP.Velocity = HRP.CFrame.lookVector * 200
			wait(CoolDown)
			DB = false
		end
		LastTime = tick()
	elseif UIS:IsKeyDown(Enum.KeyCode.W) and input.KeyCode == Enum.KeyCode.X then
		if not DB then
			DB = true
			HRP.Velocity = HRP.CFrame.lookVector * 200
			wait(CoolDown)
			DB = false
		end
	end
end)

--BACKWARD DASH
UIS.InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.S then
		local now = tick()
		local difference = (now - LastTime2)

		if difference <= DoubleTapTime and not DB then
			DB = true
			HRP.Velocity = HRP.CFrame.lookVector * -200
			wait(CoolDown)
			DB = false
		end
		LastTime2 = tick()
	elseif UIS:IsKeyDown(Enum.KeyCode.S) and input.KeyCode == Enum.KeyCode.X then
		if not DB then
			DB = true
			HRP.Velocity = HRP.CFrame.lookVector * -200
			wait(CoolDown)
			DB = false
		end
	end
end)

--LEFT DASH
UIS.InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.A then
		local now = tick()
		local difference = (now - LastTime3)

		if difference <= DoubleTapTime and not DB then
			DB = true
			HRP.Velocity = HRP.CFrame.rightVector * -200
			wait(CoolDown)
			DB = false
		end
		LastTime3 = tick()
	elseif UIS:IsKeyDown(Enum.KeyCode.A) and input.KeyCode == Enum.KeyCode.X then
		if not DB then
			DB = true
			HRP.Velocity = HRP.CFrame.rightVector * -200
			wait(CoolDown)
			DB = false
		end
	end
end)

--RIGHT DASH
UIS.InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.D then
		local now = tick()
		local difference = (now - LastTime4)

		if difference <= DoubleTapTime and not DB then
			DB = true
			HRP.Velocity = HRP.CFrame.rightVector * 200
			wait(CoolDown)
			DB = false
		end
		LastTime4 = tick()
	elseif UIS:IsKeyDown(Enum.KeyCode.D) and input.KeyCode == Enum.KeyCode.X then
		DB = true
		HRP.Velocity = HRP.CFrame.rightVector * 200
		wait(CoolDown)
		DB = false
	end
end)