How do I format this?

I have a basic outline for what I want this to do and got it working with command blocks (image).

It's basically saying this: When I shoot a spectral arrow, mount me on it. When it lands, kill it. When it's killed, give it back to me.

I know it should (probably) go in the tick.mcfunction file. I just need to know how to format it.

In the future, I might try to make it compatible with any player, but that's waaay out of my expertise right now.

Continue to help post