How to make a button to walk?

Basically, I’m working on something and at a certain point, I want the player to stop using the keyboard and start moving with their mouse by clicking a gui with arrows on the screen, literally like on mobile

A quick resume would be how do I script the same movement as pressing a key?

I tried using MoveTo() but im not sure how to implement it

HELP

You can do their currentPosition + currentCFrame.LookVector * speed

But what if i want them to move only to the left and right?

Replace LookVector with RightVector and -RightVector

I couldn’t quite get it to work…

MB.RightButton.InputBegan:Connect(function()
		char.HumanoidRootPart.Position = char.HumanoidRootPart.CFrame.RightVector * 5
	end)

HAHAHA i knew you had to be making some sort of 2d game, you could try using Hhumanoid:Move()

1 Like

But doesn’t the Humanoid:Move() function require a vector3 parameter?

Yup that could work in your case if you pass the players RightVector/-RightVector

(edit: wrong video oops)

Awesome it kinda worked! kinda…

any way to fix this?

1 Like

Um how to fix it from going in the 3rd dimension? :joy:

2 Likes

haha i mean the character walks to the right depending on which direction its facing, i dont want it to be like that

1 Like

WAIT oh im dumb okay so basically you have to use WorldSpace which would just be

Vector3.new(1,0,0) and Vector3.new(-1,0,0)

So basically global right and global left

1 Like

I think i built the game on the wrong rotation…

Do i just use different axis or is there any way to rotate the world or something like that?

Ohhh yeah your def arent on the global X axis correctly but thats fine try these ones

Vector3.new(0,0,1) and Vector3.new(0,0,-1)

Thats the uh Z axis

Works like a charm! Just one more question… any way to make it so you have to hold the button? because right now just by pressing it once the player walks permanently

Trying doing Humanoid:MoveTo(HumanoidRootPart.Position), right after doing the moving left or right, in theory this should make you move whichever direction and then stop

tumblr_58565a0cac3f4924da6fb29de57921ec_f44c34ee_540

Actually it didnt work lol, it just stops me in place, like it wont move at all, isnt there something like InputBegan but like for holding?

Wait I have a theory try to put a task.wait() inbetween

Oh well that kinda worked, but it’s not like a hold the button thing, I want it to walk as long as you’re pressing the button, and stop when you release it

thinking-hmm

Well were gonna need too see how your code is looking since my help

homelander