How to Make a Local Brick: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Jopc67
No edit summary
m Text replacement - "<SyntaxHighlight code="lua">" to "<syntaxhighlight lang="lua">"
Tags: mobile web edit mobile edit
 
(20 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{CatUp|Category:Tutorials}}
{{ScriptTutorial| Easy |Scripting}}
 
{{ScriptTutorial| Intermediate to Hard|Scripting}}


<br /><br />
<br /><br />
Line 7: Line 5:
__TOC__
__TOC__


{{EmphasisBox/start|red}}


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


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


=The Script=
=The Script=
Line 48: Line 40:
This is the code we have so far:
This is the code we have so far:


<pre>
<syntaxhighlight lang="lua">
wait()
 
local brick = game.Lighting.Brick
</pre>
 
 
==Part 2: Creating The Function==
 
Well we should know how to create a function by doing <i style="color:green">function main()</i> and, of course, ending it.
 
 
This is all the code we have written so far.  I have already added the part that'll start the function:
 
<pre>
wait()
 
local brick = game.Lighting.Brick
local brick = game.Lighting.Brick
</syntaxhighlight>


function main()
==Part 2: Adding The Code==
 
end
 
main()
</pre>
 
 
==Part 3: Adding The Code Inside The Function==


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


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


function main()
local cam = game.Workspace.CurrentCamera
local cam = game.Workspace.CurrentCamera
local brickClone = brick:clone()
local brickClone = brick:clone()
brickClone.Parent = cam
brickClone.Parent = cam
</syntaxhighlight>
end
 
main()
</pre>


==The Code==
==The Code==
Line 111: 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 124: 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}}
== See Also ==
If you're looking for something similar or closely related to this article, see these:


[[Category:Tutorials]]
*[[Local Parts]]


<div style="float:right;">Find 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