How to Make a Local Brick

From Legacy Roblox Wiki
Revision as of 03:14, 24 January 2012 by >Aboy5643 (As the Local Parts page is a more advanced, in depth version of this (by blobbyblob) I figured it deserved a link. I left jopc's little thing alone..)
Jump to navigationJump to search

This is an Easy , 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.

See Also

If you're looking for something similar or closely related to this article, see these:

Found an error? Report it to Me