How can I use move and move to on my script?

I’m making a 2D fighting game (something like street fighters) and I have already made the camera and now I need to make the movement.

I heard that I need to use move and move to on my script but I don’t know how.

I found a post on devforum that talked about the same subject and that’s where I found out that I need to use move and move to.

The problem is that I don’t know how to use them correctly and I need some help. I don’t want entire scripts for movements, I just want some examples to how to use them.

4 Likes

https://developer.roblox.com/en-us/api-reference/function/Humanoid/Move
https://developer.roblox.com/en-us/api-reference/function/Model/MoveTo

I hope these can help you. I’ve never used Humanoid:Move(), but I have used :MoveTo(). MoveTo takes a Vector3 value in it’s parenthesis, and can be used to move a model to a specific point. Example: Model:MoveTo(Vector3.new(10, 5, -3))

After looking at the devforum post, apparently the :Move() function is similar. Use it like this: Humanoid:Move(Vector3.new(10, 5, -3)) to make the character walk to a certain point

3 Likes

So let’s say I switch the D button with Humanoid:Move(Vector3.new(numbers)? If that’s what I have to do, then should I do it with input user service and unbind action all movement?

1 Like

yes

Summary

This text will be hidden

1 Like

I’m not entirely sure what you’re asking. You’re asking if you should use Humanoid:Move() when the player presses D?

You could do that, but of course you would have to update the position according to the player’s location

1 Like

Why do I need to update the position tho?

1 Like


Use my amazing drawing as an example. Point A represents the position you used in Humanoid:Move()

When the player holds down D, they’re going to move to the right and stop at point A.

You would want the player to keep moving to the right the entire time they’re holding D, or else the player will stop walking once they reach point A. so you would have to keep pushing Point A to the right of the player.

1 Like

Sorry to bother you, but can you make an example code please? If you can’t then its ok

1 Like

Yes, I will respond in 5 minutes if I can get it to work.

2 Likes

I can’t get it to work with userinputservice, I think the event isn’t detecting that D is being pressed because roblox automatically binds the D key to move to the right

Also, you should use :MoveTo instead of :Move for the humanoid, that is my mistake.

2 Likes

Did you try unbinding D first?

1 Like

I don’t think you can, because roblox automatically binds it

2 Likes

Like, I think its right movement, right?

1 Like

Well, thanks for the help man. I’ll try to figure something out.

1 Like

I’m not sure you would have to use :MoveTo at all, even on the humanoid since roblox automatically makes you move to the right when you hold D

2 Likes

yes you can

Summary

This text will be hidden

1 Like

https://developer.roblox.com/en-us/api-reference/function/Humanoid/MoveTo
Just read the documentation for Humanoid:MoveTo.

3 Likes