Out and back code better

I want to make it so when the left mouse button is pressed the given entity moves away from the player and then comes back at a certain distance.

Hi @Mason_Rocchio! You already have a topic about this?

https://forum.playcanvas.com/t/solved-out-and-back/

I know but when I hit the mouse it glides away but it just teleport’s back I want it to glide back to the player Also I want it to glide until it is a certain distance then it glides back.

That’s how you made the script.

I suggest to store the original value of the axis, before you move it a way. Then move it back the same way, until the original value is reached.