Raycasting Issue

I have been working on a knife/revolver type combat game for a while now. To handle damage i send a request to the sever with x tick, and the server has a table structured somewhat like this:

RewindData = {tick = {NamesOfPlayers = {CharacterCframe, Character}}}

The damage scripts gets the closest time and gets the RewindData. Then I cast a ray from the Start position of the ray sent from the client ( the client performs its own raycasting and this is also sent to the server ) and with the direction as CharacterPosition, I Then check if the distance below ( (8.5 * Attacker:GetNetworkPing() * 1000) * 0.25) )

I’m sorry for the terrible explanation, this is the best I can explain this(:sob:)

This setup works fine, but its a little too messy and was wondering if theres an easier/more secure way of doing this. If you need to know anything else about my code, let me know!

-------------- bump --------------