For future reference, please refer to this page: Using code tags properly
It shows you how to insert code, looking nicely, on the forums… rather than pasting a screenshot, which is less nice. However, I can easily read your small piece here.
To the best of my knowledge, they should both be working equally well.
Nothing else getting in the way of your finger maybe? You have at least 3 scenes in the build? (Though, this would fail even in the editor, I think)…
Not sure what else it could be. Double check that you have an EventSystem and a PhysicsRaycaster present in the scene, in case somehow they were removed between testing in the editor and the build?