Your current code doesn't have any way to stop the motor; it needs a final else clause.
Other than that, I don't see the issue in this snippet of code.
The next few things to check:
- Did you verify that you're getting the values you expect from the GetX()?
- Is the spike control wire plugged into a relay port (not a PWM or DIO or analog port)?
- Is relay of the Relay class and initialized to use the same port as the wiring is connected to?
- Are the wires in the right orientation (both power and control), and are you getting a good connection?
- Is the fuse on the spike blown?