The ELSE IF can execute if there is no collision, in which case “hit” is not populated. Just check the collision in the first IF, then use an “if (spent == false)” / “else if (hit.transform.tag == “Target”)” branch within the first IF.
The problem is with your placement of if…else loop.
Your else loop is for your if(Physics.Raycast...) loop which makes your hit object unavailable in your else loop since your hit object is for Raycast loop only.
I think your want to put your else loop for if(hit.transform.tag == "Floor"){ line of code.
The reason because hit is null. You tried to check hit.transform.tag while the raycast might not hit any object. I think you putted the else if in the wrong block. It should be after if(hit.transform.tag == "Floor") block which is: