This should be run as a script in server script service.
After you try this, please post any errors you are getting, this will make it much easier to fix.
Additional info:
Please indent, it makes code much easier to read.
Also, put your code inside three backticks ```. It properly formats and adjusts code, and is also quite helpful.
I hope this helps,
Someperson576