The Spanish X has two sounds.
One sound occurs when the letter “X” is found between vowels. An “X” between vowels creates the sound of an English “KS.”
The other sound of a Spanish “X” occurs when the “X” falls before a consonant. In this case, the “X” takes the sound of an English “S.”