Raycast Function

DISCLAIMER: I'm nearly brand new to datapacks and have a bit of understanding on how they work, but am largely new to them.

I'm trying to make a custom sword that when you right click, instantly teleports you 50 blocks in the direction you're looking (with cooldown).

Step 1 of course is to create a raycast function to get the teleportation working. I've downloaded a couple from the internet but they don't seem to work (probably because they were made for 1.15-1.16).

Is anyone here perhaps able to help me create a working raycast function that goes for 50 blocks (or stops when it hits a block).

Continue to help post