Look at page 68 of
https://www.oaaust.com/FX2N Hardware Manual-2.pdf
They show connection of an external transistor. Your case is the second(figure 5.2), but you use a PNP sensor, while with this cabling you must have a NPN. And this is why you get a half 24V (12V).
You can adapt the circuit to use a PNP, but you must use additional components, or put S/S to 0V, in this case the functions of the PLC would be upside down and other functions if presents may not work.