[SOLVED] Attack Code Not Working

So I am trying to make a 2D game where when you click “Z”, the attack trigger teleports to the player. The code isn’t working and it says that it cannot read the properties of “root”.

Hi @Alec_Sun and welcome!

You need to create a global variable before the initialize function like you already do, but you need to define it inside the initialize function.

Also your third line of code should be placed inside the initialize function.

Thanks for the help! But I am confused on what you mean by “define it inside the initialize function”. Could you please elaborate? Thanks!

NVM I fixed it