What's wrong with this mouse warping script?

When i click it doesn’t warp me I have to hold down the left mouse button and then turn it on for it to warp me.

if (playerenters) toweapons WarptoMouse; {
  OnOff();
  warper();

  function OnOff() {
    if(weaponfired) {
      if(!this.warp) {
        setplayerprop #c,ON;
        set this.warp;
      }
      else {
        setplayerprop #c,OFF;
        unset this.warp;
      }
    }
  }
  function warper() {
    if(this.warp) {
      if(leftmousebutton) {
        this.mousex = mousex - 1.5;
        this.mousey = mousey - 2;
        playerx = this.mousex;
        playery = this.mousey;
      }
    }
  }
}

You’re not checking if a mousebutton is pressed, use

 if (mousedown && leftmousebutton) 

Thank you that fixed it.

[quote]if (playerenters) { <- Add that
toweapons WarptoMouse; { <- get rid of that
OnOff();
warper();
} <- Add that

} <- get rid of that[/quote]

Also why do you have a weaponfired inside of a function? You can’t activate it from inside there…

Congratulations to mark for actually doing some scripting though, instead of begging for someone to do it for him.

[QUOTE=Beholder;56789]

Also why do you have a weaponfired inside of a function? You can’t activate it from inside there…
[/QUOTE]

Oh i did not know that.

You can’t learn if you beg someone else to do it.

That’s how I learned lol.

Well that’s not how i like to learn :stuck_out_tongue:

I wish all the newbies were like Mark. :[