How to make a spark spawn at the end of a raycast

how can i make a entity like a spark spawn at the end of the raycast

Do you mean a particle effect or something?

yes