How to Make a Local Brick: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Trappingnoobs
Removed useless main function
>Trappingnoobs
Removed EmphasisBoxes. Overused and prety much the entire page used them.
Line 5: Line 5:
__TOC__
__TOC__


{{EmphasisBox/start|red}}


=Intro=
=Intro=
Line 19: Line 18:
So let's start scripting!!
So let's start scripting!!


{{EmphasisBox/end}}
<br />
{{EmphasisBox/start|green}}


=The Script=
=The Script=
Line 80: Line 74:
This is just a simple code that can be edited however you like, so have fun with it.
This is just a simple code that can be edited however you like, so have fun with it.


{{EmphasisBox/end}}
{{EmphasisBox/start|cyan}}


=Other Ideas That You Could Do=
=Other Ideas That You Could Do=
Line 93: Line 83:
There are so many ideas that I can't list them all.
There are so many ideas that I can't list them all.


{{EmphasisBox/end}}


<div style="float:right;">Find an Error? Report it to [[User:Jopc67 | Me]]</div>
<div style="float:right;">Find an Error? Report it to [[User:Jopc67 | Me]]</div>

Revision as of 18:15, 9 July 2011

This is a Intermediate to Hard, Scripting related tutorial.





Intro

Brick In Camera

I'm sure your wondering What are local bricks?


Well the answer is in its name. If you are familiar with a LocalScript, then you should know it runs on the client and not on the server. A local brick is not on the server workspace, but instead it's in the camera.


So let's start scripting!!


The Script

Let's start off by adding a part or brick into the Lighting and naming it Brick.


Next, let's insert a LocalScript into the StarterPack. (LocalScripts only work in the StarterGui, the Tool/Hopperbin, and StarterPack)


Open up the LocalScript and let's talk about the code we'll put in.


Part 1: Determining What To Add Before The Function

The script will usually work once because it starts too soon. The only way to fix that is by adding a wait() before all the coding.


We also probably want to make a shortcut to the brick we made earlier by adding local brick = game.Lighting.Brick.


This is the code we have so far:

local brick = game.Lighting.Brick

Part 2: Adding The Code

Lastly let's declare the camera and the cloned brick. We clone the brick so it can be used more than one time.


Let's first declare the camera by adding local cam = game.Workspace.CurrentCamera to the script.


Next let's declare the cloned brick by adding local brickClone = brick:clone().


Now finally let's move the cloned brick in to the camera by adding brickClone.Parent = cam.


The final code should look something like this:

local brick = game.Lighting.Brick

local cam = game.Workspace.CurrentCamera
local brickClone = brick:clone()
brickClone.Parent = cam

The Code

This code can be improved in a lot of ways. For example every time you die a new brick will be added into the camera.


This is just a simple code that can be edited however you like, so have fun with it.


Other Ideas That You Could Do

  • A Single Player RPG.
  • A Staircase Only For You.
  • A Jail That Only The Jailed Person Can See.

There are so many ideas that I can't list them all.


Find an Error? Report it to Me