Why is this still running even when it shouldn't

So basically I have a script that handles attacks. BUT one of the attacks runs even when I use another one. Anyone know why?

			if uis:IsKeyDown(Enum.KeyCode.X) and uis:IsKeyDown(Enum.KeyCode.W) then
				print('Keys X and W pressed')
				attackEvent:FireServer('UpAttack')
			elseif uis:IsKeyDown(Enum.KeyCode.X) and uis:IsKeyDown(Enum.KeyCode.S)  then
				attackEvent:FireServer('DownAttack')
			elseif uis:IsKeyDown(Enum.KeyCode.X) and not uis:IsKeyDown(Enum.KeyCode.S) and not uis:IsKeyDown(Enum.KeyCode.W) then -- this is what is running. Its not suppose to when the S key is down or the W key
				attackEvent:FireServer('ForwardAttack')
			elseif uis:IsKeyDown(Enum.KeyCode.G) then
				
			elseif uis:IsKeyDown(Enum.KeyCode.Z) then
				
			elseif uis:IsKeyDown(Enum.KeyCode.R) then
				
			end
elseif uis:IsKeyDown(Enum.KeyCode.X) and not uis:IsKeyDown(Enum.KeyCode.S) and not uis:IsKeyDown(Enum.KeyCode.W) then

not keydown s not keydown w

1 Like

Once it detects you pressed X, it executes (since the other conditions are if other buttons are not pressed) while all the above if statements check for another condition.

Edit: The only 2 ways I can think of to fix this, are

  1. Check for another condition for that one just like all the other ones
  2. If you want the player to only have to press one key for that attack, then you can make that 1 attack’s key something else other than X.
    But yeah it’s a pretty confusing thing to fix.