Trouble with raycaster

i've been working at this for 4 hours or something idk why it isn't working please help. i've been trying to make the raycaster check the next edge of the grid space?
sorry the scripting area is a bit messy