How to Make a Local Brick: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Jopc67
m Text replacement - "<SyntaxHighlight code="lua">" to "<syntaxhighlight lang="lua">"
Tags: mobile web edit mobile edit
 
(8 intermediate revisions by 3 users not shown)
Line 40: Line 40:
This is the code we have so far:
This is the code we have so far:


<code lua>
<syntaxhighlight lang="lua">
local brick = game.Lighting.Brick
local brick = game.Lighting.Brick
</code>
</syntaxhighlight>


==Part 2: Adding The Code==
==Part 2: Adding The Code==
Line 59: Line 59:


The final code should look something like this:
The final code should look something like this:
<pre>
<syntaxhighlight lang="lua">
local brick = game.Lighting.Brick
local brick = game.Lighting.Brick


Line 65: Line 65:
local brickClone = brick:clone()
local brickClone = brick:clone()
brickClone.Parent = cam
brickClone.Parent = cam
</pre>
</syntaxhighlight>


==The Code==
==The Code==
Line 83: 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.


== See Also ==
If you're looking for something similar or closely related to this article, see these:
*[[Local Parts]]


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

Latest revision as of 05:53, 27 April 2023

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