Move a Dummy Via Left and Right Arrow Keys

I am trying to be able to move a dummy left and right via the left and right arrow keys. I know that going left would be Vector3.new(-1, 0, 0) and going right would be Vector3.new(1, 0, 0), but I’ve tried many things that all don’t work.

I saw a similar post about moving a part via the WASD keys, and I tried a similar formula, except with using Humanoid:MoveTo(targetPosition), but in all it still did not move.

Any help is greatly appreciated.

2 Likes

The Humanoid:MoveTo(targetPosition) moves to one point in the 3d game space. I believe you are concerned with direction of movement so have you tried dummyHumanoid:Move(direction)?

1 Like

This sadly makes it infinitely move, and I’m having trouble figuring out why.

If dummyHumanoid:Move(direction) is used, according to documentation it will continue until it is given a new value. The simple solution here is to have a key state. If the A key is down, it goes left, and while its up, it overrights the direction to be 0. The similar concept would apply to the D key.

Try that out.

Actually, nevermind, this did work. I just had to set the direction to Vector3.new(0,0,0) when no keys were being pressed. Thanks!

1 Like