This video will show you
how to make a simple car on Roblox.
Cars can be used to transport players across maps
or even for racing.
Use our clickable sections to navigate this video.
Click on the model tab and make sure that
"Join Surfaces" is unchecked.
Then check the "Move" button in the "Snap to Grid" section
and set its value to 1 stud.
Click on the home tab and insert a part for our chassis.
Use the scale tool to resize this part
and name it "Chassis" in the properties window.
Insert four more parts using the part button.
Select all four of them and set the size
to "1,1,1" in the properties window.
Name the parts "PartA."
And make sure that "CanCollide" is unchecked
for these parts in the properties window.
This is important because otherwise
the wheels would collide with the joiner parts,
limiting the ability to turn the car.
Now check the "Join Surfaces" button in the model tab
and drag each part onto the edge of the chassis
for each wheel.
Make sure the white border appears to show
that the part will stick to the chassis.
If this doesn't appear, you need to set Join Surfaces.
Right-click and select "Insert Object"
and choose a "VehicleSeat."
Drag the vehicle seat on top of the chassis.
Check for the white border
to ensure it has been joined to the chassis,
then rotate it to be facing the front of the car.
Now let's set up the steering ability
for the front of the car.
Select two parts named PartA at the front of the car
and duplicate them by right-clicking
and selecting "Duplicate."
For each part, use the move tool
to drag it a few studs away.
Repeat this for the other side.
As I said, don't worry about doing the back of the car,
just the front two.
Select both of these new parts and call them "PartB"
by setting the name property in the properties window.
So on the inside, we have PartA,
and on the outside, we have PartB.
Now click on the model tab
and select the arrow underneath the create button
in the constraint section and select "Hinge."
Click the top middle of the PartB,
and then click the top middle of the PartA.
Repeat this for the other side.
Don't forget to select the outside part first.
Now select both hinge constraints from the explorer,
and in the properties section,
set the name of them to "SteeringConstraint."
Then scroll down and set the actuator type to "Servo."
Set the angular responsiveness to 45,
the angular speed to 10,
and the servo max torque to 10,000.
Click on the arrow underneath the part button
and select a cylinder.
Then insert three more cylinders.
These are going to be our wheels.
Select them all, and in the properties window,
set their size to "1,4,4."
Then drag each wheel to be in line with the other parts
so that the square part is aligned
with the middle of the wheel.
Now you may need to change the Snap to Grid setting
in order to get the wheel in the middle of the other parts.
I set mine to 0.5.
Firstly, I moved the wheels to the correct area of the car,
and then I set the Snap to Grid to 0.5
to align them correctly.
I am also selecting all of the other parts of the car
and moving them up in order to place them
in the middle of the wheel.
Make sure to leave a couple of studs' gap
in between all of the parts
so that we can set up their constraints.
Now click on the arrow underneath
the create constraint button in the model tab
and select "Hinge" again.
Let's do the front wheels first,
since they're slightly different to the back ones,
since we've got this extra PartB.
Click the middle of the wheel
and then click on the middle of the outside part's face
which is closest to the wheel.
Repeat this for the other wheel
at the front on the other side.
Take your time if you need to,
because we need to get this right.
For the back wheels,
select a hinge from the constraints panel
and click in the middle of the wheel,
and then click in the middle of the PartA.
Again, repeat for the other side.
Select the hinge constraints for each wheel
in the explorer panel and make sure to not select
the steering constraints.
Name these constraints "WheelConstraint,"
and then scroll down and set the actuator type to "Motor."
Set the motor max torque to 10,000.
A quick tip: If you're struggling to position the camera
to create these constraints,
you can hold down shift on your keyboard.
This will slow the camera down
so that you can get into those tight spaces.
And a quick reminder:
Make sure that your PartA and PartB parts,
that CanCollide property needs to be unchecked.
Also make sure that your steering constraints
start on the outside and move inwards.
You can check this by setting
the "Constraint Details" property in the top menu.
And this will show all of your hinge constraints
that we've created.
You can tell by the brown circle on the outside
which is correct.
Finally, select each set of parts and wheels
and group them together for each wheel.
You should have four models,
two of which contain two parts
and one wheel, for the front;
and two which contain just one part
and one wheel, for the back.
Name the models "BackLeft," "BackRight,"
"FrontLeft," and "FrontRight."
Then select these models as well as the car
and chassis and group them together.
You can press control plus G
or command plus G on a Mac
to group items together.
Insert a script into the car
by clicking the plus icon and selecting "Script."
For the sake of time,
we're going to speed up the coding parts.
Pause at any time to follow along.
Firstly, we create variables
for our seat and four sets of wheels
so that we can easily reference them later on.
Then we're going to set two variables
to hold our steering angle and the max speed of the car.
Then we're setting up two events.
One event will fire when the steering of the car changes
from the input of the vehicle seat.
When this changes, we'll set the target angle
of our steering constraints,
which will turn the wheels left and right.
Our second event is for the throttle.
When that changes by the W or S keys being pressed,
that will change the angular velocity of the wheels,
moving them forwards and backwards.
For the right wheels, we multiply the speed by a negative
to make sure that the car doesn't spin out.
If you're copying the code from the video,
don't worry about the arrows or the dots on my screen.
This is just used to indicate a space or a tab.
They aren't characters which I've typed into the script.
Finally, click "Play" to test your car.
If your car doesn't work,
make sure that the front of the vehicle seat
is facing in the same direction as the car.
You might need to rotate it by 180 degrees.
And also make sure that you copied all of the properties
for our hinge constraints correctly,
you made sure to check the Join Surfaces tab
when assembling certain parts of the car,
and also make sure that you set the CanCollide
of the parts A and B to unchecked.