ImaGani Do you have a screen protector applied? Some screen protectors, in particular when the surface is smudged by oil and grease from your skin, can easily “block” the proximity sensor and render it faulty. Try cleaning your screen and see if it makes a difference, if not, remove the protector and try again - if it still not works even without a protector, there really is a chance the sensor might be broken.
If it works without the screen protector, you’d have to look for a replacement. Unfortunately most protectors don’t come with proper cutouts for the sensor area anymore.