click ang go question

Hern4n

  • Posts: 1
Hi, I'm trying to make an actor who moves to the position of a second actor when he clicks on the second and stop when they are in the same position, the problem is that I can not make it work.
the idea is a player on a row of five blocks and when it clicks one of these blocks the player automatically goes on the position of that block.
I fail to make it work my code is below if anyone can help me I appreciate it

player behavior

if mouse was pressed
  if x of self >posx (global variable that stores the x position of a block when is clicked)
    set x-speed to -1 for self
  otherwise if x of self >posx
    set x-speed to  1 for self
  otherwise
    set x-speed to 0 for self

block behavior

if mouse was pressed on self
   set posx to x of self

thanks