Hitdistance would return 0 when the ray doesn't hit anything. Check that there are in fact obstacles and that you've configured them correctly in LOS behavior.
Or maybe the ray hits the player object itself, or some other object attached to the player.
It's difficult to speculate without the project file.
apologies for the delayed response but ive done a bit of tweaking, and ive got it to "half work" of a sort. it is shooting the ray out past 0 pixels now, but it seems to sometimes randomly not go far enough, like, it will shoot out but it will fall short of the solid object, the distance it falls short of seems random, at some points it works perfectly and goes to the wall, at other times it practially goes nowhere, like 5 pixels out from the player when the wall is sat 500 pixels out. completely random. ill send the project file here:
https://download1322.mediafire.com/67biei4kdr5gWOXfPnmzV3TJAQgSnjQiPaO54nrN4jT6H4F8ANUZE4gg0NLoDG2lWVlK42VW1Ogce2iKCcFmvpABWGKrVEIyInuLIjF1h1hBr6E3UCcDqZBVDHP30OwM-Edbrxr43FbGgXobfeQXzhAQ9KF561p5hEQ1c6QmZ3g9_jc/lwcth4qd9w2qzj2/2d+Platformer+Shooter+Game.c3p
When ingame, you can use left click to shoot the laser, but you will find the length of the laser is seemingly random.