How to make a sword that shoots particles that do damage?

//ads -- adsterra.com -- native banner
?>
I want to make this sword that, when you right/left click it, it summons particles that go in a straight line and deal damage to anything they touch. I have only basic knowledge on stuff like this, and I think the first step would be making a scoreboard that detects when the player right clicks with the sword. However, I do not know the rest. Does anyone have an idea on how this is done in java 1.16? Thanks!
Pictures about "How to make a sword that shoots particles that do damage?"



How do you get infinite attack damage swords in Minecraft?
In Minecraft, you can't have an "infinity" damage sword. This is because computers, which Minecraft runs on, don't understand "infinity". Computers store numbers as a series of 1s and 0s, really, "on" and "off". Minecraft stores numbers with up to 32 of these ons and offs.Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Mikhail Nilov, cottonbro, Mikhail Nilov, Monstera