Can you please format your code by using the </> button when editing a message or use triple backticks like this: ```code``` → code?
You were on the right track! What you need is classes and objects in order for your spaceships to have their own data (position, lights, size…) and be able to do actions on them.
You can check an old post I did on the subject, it should be pretty straightforward to implement!