You won’t lose the script – all scripts you create are saved in the Code sidebar.
You need to delete the asset, then select the correct layer and place the asset in your level.
Then open the CODE sidebar, select the correct script, and click on the object to reattach the script.