How can I translate these scripts into a tool?

Basically, there was this tutorial I saw on youtube that was for an advanced, smooth flashlight

i asked the creator for help to incorporate this into a tool but after some pretty useless answers from the creator, I decided to ask for help here
https://www.roblox.com/library/8849676032/Ray-Traced-Flashlight

here is the link for the tool, for you all to look through it yourself.

this code uses a part attached to the head of the player that uses a spotlight, I want to translate this into a tool but every time i try to do it, it lags a LOT and gives me a million errors per second. Any help is appreciated

Thank you in advance

Can you provide a script and the errors your receiving