Car scripting, Where To Start?

I am trying to make a car without using things like motors etc.

what i need to make is:

  1. Vehicle braking when i press space instead of the player just jumping out of the seat
  2. Steering and controlling the vehicle with WASD and not using the arrow keys.
  3. Acceleration and suspension

Where would i start and what should i do?

I also need to build the car but idk if i should just do a brick with 4 wheels or what

7 Likes

If this is your first time making a car, I would just start with making a dummy that has four wheels and a brick to sit on. For WASD, you could map the keys individually and have them add velocity to the vehicle. For the jumping, you can set a humanoids jump power value- (i’m not sure if this will actually work, but it simulates not jumping)
Acceleration would just be a hidden value called “speed” that you have perimeters to go up wither +1 a second, or +2, depending on the current velocity.

1 Like

this is not what i am trying to make, that is too simple. i am trying to make a similar system to vehicle simulator

2 Likes

Start simple, build the seat first and get the player to stay in place. Once you have completed this you can build a simple car with only a body wheels and the seat. Use context action service for the steering and controls. Add velocity to the body when a key is pressed. Also I don’t think that using space for breaking is the best idea the player needs a way of getting out of the car.

2 Likes

they will use F to get out of the car. it will be clearly indicated too so players will know unless they are like 3

Also, userinputservice would not work because i will have to use a server script to make it more secure due to the client being able to change the value of it if they used exploits

1 Like

Shouldn’t you use ContextActionService instead of UserInputService for the controls?

It could interfere with some of the controls Roblox has implemented.

1 Like

Now that I think about it that would be the better way to do it. I will change what I had said earlier.

3 Likes

as i said, a local script is too easy to exploit and EVERY vehicle movement script should be in a server script

2 Likes

Use a remote event so the client detects when a key is pressed and the server handles it.

2 Likes

What I would do is make it when a player presses a key bind near a car they get welded to the car. Movement of the car should use BodyPositions and BodyAngularVelocity to control movement and steering. Have the car fire a Ray forward and multiply by the car speed. Then the car will move forward or backwards depending on the limits you give it. Make a simple chassis without wheels and you can add them later. Good luck!

2 Likes

https://devforum.roblox.com/search?q=creating%20a%20chassis%20category%3A55

Question’s been asked before. Have you tried searching for these threads first? If you have, did any of the posts help you learn something new about programming cars? I’m sure there’s some helpful information to be extracted out of these threads.

Now just a quick side note. I tried doing this once and it did not go well. Roblox’s Physics Engine is not vehicle friendly unless you know what you’re doing. Most vehicles use springs now and a bunch of damping so wheel-ground collisions don’t cause havoc. I highly recommend the ContextActionService as have other people if you’re doing anything such as keybindings for getting in vehicles. VehicleSeats already come with built-in values for movement to explain direction. Alternatively you can make your own system to do this.
Set the NetworkOwnership of the vehicle to the person driving