It looks like you’ve passed your code through a language translator. I have no idea why you’ve posted it several times.
The 2D forum isn’t for general scripting questions, use the Scripting forum for that here. I’ll move your post.
Also, you must use code-tags and not plain text when posting code. You can edit your posts too, you don’t need to post it several times like a chat.