How to make a car: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Cecibean
m Minor edits
>Cecibean
m Minor edits
(No difference)

Revision as of 12:26, 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

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.