How can I use coroutines to do car movement?

If I have an

local keypressed = nil

inputbegan event

inputended event

I want the events to either create or resume or pause coroutines.
So if I am pressing W and holding it then I want the coroutine for moving forward to be resumed and the coroutine for moving backwards to be paused.

I prefer to not use while loops or repeat loops as I want the movement to be instant

1 Like

Not sure why you want to use coroutines

But here is a video where you can control a car with no loops and is instant

1 Like

You don’t really need to make a new coroutine. Actually you don’t need the keypress events either.

You can connect to RunService.Stepped and check the value of UserInputService:IsKeyDown every frame to figure out if you should move forward, backward, or neither.

There are no short cuts when its about making such videos.
That video is informative to those who want to make what he’s showing there.
He explained every step he did in this tutorial, to make it as clear as possible. Thats why it’s a 1 hour long.

Yes, 1 hour can be exhausting, but sometimes there are no other choices.


It uses a server script.

There’s a lag.

I use localscripts and UIS and make it all client sided

what uses a server script

my video does not use a server script it uses a localscript inside startercharacterscripts

try it for your self here
Car.rbxl (71.9 KB)