How to make a car: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Cecibean
>Cecibean
Line 63: Line 63:
=== Creating the Parts Model ===
=== Creating the Parts Model ===


This model will hold all the key pieces that will make the car driveable.
This model will hold all the key pieces that will make the car driveable.  Follow these steps to add the necessary pieces:
 
*Select the '''Parts''' model and insert a CFrameValue object.  Name this value '''OriginCFrame'''.
*Insert into the '''Parts''' model a script object.  Name this script '''CarScript'''.
*Insert into the '''Parts''' model a Seat object.  Note, this seat will be the driver's seat.
::*Change the [[Size]] of the seat to be 2x2 (2 for x axis, and 2 for z axis.)
::*Change the [[formFactor]] of the seat to be '''Plate'''.
::*Change the [[BrickColor]] property to any color.  In this example, the seat is Black.
*Insert into the '''Parts''' model a Part object.  Name it '''Engine'''.
*Insert into the '''Parts''' model an additional 4 Part objects.  Name the 4 new bricks these names: '''LeftWheel1''', '''LeftWheel2''', '''RightWheel1''', '''RightWheel2'''.


=== Creating the BodyKit Model ===
=== Creating the BodyKit Model ===
s
s

Revision as of 13:15, 11 December 2008

Introduction

This tutorial will demonstrate the basic steps needed to create a car from scratch. It will also describe how to add additional features to the car. The scripts used to make the car move are derived from the basic plane scripts. In that sense, the car has many of the same key objects as the plane. For this tutorial, the plane scripts have been simplified and customized to make the car-specific.

Creating a Car From Scratch

These instructions describe the building of the car within Roblox Studio.

The car will consist of these models:

  • CarGarage
  • Car
  • Parts
  • BodyKit

Creating the CarGarage Model

The purpose of CarGarage model is basically to hold the script needed to re-generate the car after a player drives away. Follow these steps to create the CarGarage model and add the necessary objects which will allow the car to regenerate.

  • In the Explorer window, select the Workspace
  • From the Insert menu, select Object > Model
  • Rename this new model CarGarage
  • Select the new CarGarage model
  • From the Insert menu, select Object > IntValue. Rename this value Regen
  • Select the CarGarage model, and insert a Script object. Rename this script RegenScript. Add the following code into the script.

system = script.Parent     -- gets the Garage model
model = system.Car         -- gets the Car model
backup = model:Clone()     -- creates a copy of the Car model
regen = system.Regen       -- Saves the integer value stored in the Garage's Regen variable

function checkRegen()
	if regen.Value == 1 then          -- When the player starts driving the car, the script
					     -- sets this value to 1
		model = backup:Clone()    -- copies the copy of the Car
		model.Parent = system     -- adds the plane to the Garage
		model:MakeJoints()        
	end
end

regen.Changed:connect(checkRegen)         -- When a Car is created, the regen value changes 
                                          -- from nil to a value - triggering this call.


Creating the Car Model

The Car Model will hold all parts that are needed to make the car. Follow these steps to create the structure of the Car:

  • Select the CarGarage Model and insert an object Model. Name this new model Car.
  • Select the Car model, and insert an object IntValue. Name this value Stunt.
  • Insert into the Car model two additional models - name them Parts and BodyKit.
  • The structure of the CarGarage model should now look like this:

Creating the Parts Model

This model will hold all the key pieces that will make the car driveable. Follow these steps to add the necessary pieces:

  • Select the Parts model and insert a CFrameValue object. Name this value OriginCFrame.
  • Insert into the Parts model a script object. Name this script CarScript.
  • Insert into the Parts model a Seat object. Note, this seat will be the driver's seat.
  • Change the Size of the seat to be 2x2 (2 for x axis, and 2 for z axis.)
  • Change the formFactor of the seat to be Plate.
  • Change the BrickColor property to any color. In this example, the seat is Black.
  • Insert into the Parts model a Part object. Name it Engine.
  • Insert into the Parts model an additional 4 Part objects. Name the 4 new bricks these names: LeftWheel1, LeftWheel2, RightWheel1, RightWheel2.

Creating the BodyKit Model

s