::* Beware objects used in tutorial are depricated in newest version of roblox studio.
::* Insert into the Engine brick a BodyPosition object.
:::* Set maxForce values for x, y and z to 0.
::* Insert into the Engine brick a BodyVelocity object, and name it Drift.
:::* Set maxForce values for x, y and z to 0.
:::* Set velocity values for x, y and z to 0.
* Insert into the Parts model an additional 4 Part objects. These bricks will become the wheels of the car. Name the 4 new bricks these names:
LeftWheel1, LeftWheel2, RightWheel1, RightWheel2. For each of these 4 wheel bricks, do the following:
::* Make the BackSurface, BottomSurface, and TopSurface Smooth
::* Make the Shape property Cylinder.
::* Make the size (3,3,3)
::* Make the formFactor property Symmetric.
::* Set the BrickColor property to Black
At this point, you should have these pieces in your workspace:
Assembling the Parts===
Assemble these key pieces of the car as follows:
* Place the Seat on the front section of the Engine brick.
* Select the 4 wheels, and change the FrontSurface to Hinge. This will show you which is the front of the wheel.
* Place the wheels next to each side of the Engine, where wheels go. Make sure the front surface of the wheel is facing to the front of the car.
* Make sure the Left wheels are on the left side of the car - On your left if you were sitting on the seat facing forward.
* Make sure the Right wheels are on the right side of the car.
* The wheels should look like this now:
* Select the two left wheels, and change the RightSurface to be Motor.
* Select the two right wheels, and change the LeftSurface to be Motor.
* Now you need to move the Engine brick up a little, so the middle of the brick will align with the motor hinge of each wheel.
* NOTE: Since it can be difficult to move the wheels while they are inside the model, you may drag the wheels to be under the Workspace object in the Explorer window. This will allow you to move them with the move tool, to make sure they are attached properly to the engine brick. Once that is done, drag the wheels to be back under the Parts model.
* Make sure the hinges of the wheels (for the FrontSurface) are pointing towards the front of the car.
* Move each wheel so that the motor hinge is inside the Engine brick.
* Change the FrontSurface to Smooth for each of the 4 wheels.
Adding the Car Tool===
Follow these steps to add the Car Tool to players as they enter the game.
* Select the Car Tool and insert a script object into it. Name the script CarDriver
* Copy the following code into the script.
bin=script.Parent car=nil hold=false local debounce = false local cardebounce = false local stuntdebounce = false local controlling = false function computeDirection(vec) local lenSquared = vec.magnitude * vec.magnitude local invSqrt = 1 / math.sqrt(lenSquared) return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt) end function move(target, engine) local origincframe = engine:findFirstChild("BodyGyro").cframe local dir = (target - engine.Position).unit local spawnPos = engine.Position local pos = spawnPos + (dir * 1) engine:findFirstChild("BodyGyro").maxTorque = Vector3.new(9000, 9000, 9000) engine:findFirstChild("BodyGyro").cframe = CFrame.new(pos, pos + dir) wait(0.1) engine:findFirstChild("BodyGyro").maxTorque = Vector3.new(0, 0, 0) engine:findFirstChild("BodyGyro").cframe = origincframe end function findCar(player) local list = player.Character:GetChildren() for x = 1, #list do if (list[x].Name == "Car") then local weld = list[x]:FindFirstChild("Parts"):FindFirstChild("Seat"):FindFirstChild("SeatWeld") if (weld ~= nil) and (weld.Part1 == player.Character:FindFirstChild("Torso")) then return list[x] end end end return nil end function onButton1Down(mouse) local vehicle = findCar(script.Parent.Parent.Parent) if vehicle ~= nil and debounce == false and cardebounce == false then debounce = true controlling = true while true do wait() local engine = vehicle.Parts.Engine local position = mouse.Hit local target = position.p if engine ~= nil then move(target, engine) end if cardebounce == true or controlling == false then break end end wait(.1) debounce = false end end function onButton1Up(mouse) controlling = false end function onSelected(mouse) mouse.Icon = "rbxasset://textures\\GunCursor.png" mouse.Button1Down:connect(function() onButton1Down(mouse) end) mouse.Button1Up:connect(function() onButton1Up(mouse) end) mouse.KeyDown:connect(onKeyDown) end function onKeyDown(key) if (key~=nil) then key = key:lower() local vehicle = findCar(script.Parent.Parent.Parent) if (vehicle==nil) then return end car = vehicle.Parts local engine = vehicle.Parts.Engine local r1 = engine.Parent.RightWheel1 local r2 = engine.Parent.RightWheel2 local l1 = engine.Parent.LeftWheel1 local l2 = engine.Parent.LeftWheel2 if (key=="x") and cardebounce == false then r1.LeftParamB= 0 r2.LeftParamB= 0 l1.RightParamB= 0 l2.RightParamB= 0 end if (key=="y") then r1.LeftParamB= -1 r2.LeftParamB= -1 l1.RightParamB= 1 l2.RightParamB= 1 end end end bin.Selected:connect(onSelected)
Testing your Car===
The car frame is ready to be tested. Save your work and run it in either Test Solo mode, or Start Server and add a player to see if any error messages come up. The Car Tool has these commands:
* y will start the car. The car should start moving as soon as y is pressed.
* x will stop the car.
* Clicking the mouse will make the car turn in the direction of the click.
* If the car doesn't move, but the mouse click makes it change direction, then you need to review every brick to make sure it is pointing forward (change the FrontSurface to hinge to verify).
* Verify the BodyGyro, BodyPosition and BodyVelocity objects in the engine have their values set to 0 - per the instructions.
* Verify the name of your model matches the instructions, or that you have changed the scripts accordingly.
Creating the BodyKit Model===
Now that the basic frame of the car is working, it can be completed to look as desired. Any additional bricks or parts should be added to the BodyKit model. The seat may be placed anywhere on the car, it does not have to sit on the engine brick. Here are some ideas for making the car look realistic:
* Add a floor and sides to the car
* Add a windshield using a mesh and a semitransparent brick
* Add more seats
* Add headlights and brake lights.
* Look through the free models for ideas on how to complete your car structure.
As the final shape of the car is developed, test the car by driving it - to ensure a change didn't break it.