How to Make a Local Brick: Difference between revisions
>Jopc67 No edit summary |
m Text replacement - "<SyntaxHighlight code="lua">" to "<syntaxhighlight lang="lua">" Tags: mobile web edit mobile edit |
||
(24 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{ScriptTutorial| | {{ScriptTutorial| Easy |Scripting}} | ||
<br /><br /> | <br /><br /> | ||
Line 5: | Line 5: | ||
__TOC__ | __TOC__ | ||
=Intro= | =Intro= | ||
Line 19: | Line 18: | ||
So let's start scripting!! | So let's start scripting!! | ||
=The Script= | =The Script= | ||
Line 46: | Line 40: | ||
This is the code we have so far: | This is the code we have so far: | ||
< | <syntaxhighlight lang="lua"> | ||
local brick = game.Lighting.Brick | local brick = game.Lighting.Brick | ||
</ | </syntaxhighlight> | ||
==Part 2: Adding The Code== | |||
==Part | |||
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 88: | Line 59: | ||
The final code should look something like this: | The final code should look something like this: | ||
< | <syntaxhighlight lang="lua"> | ||
local brick = game.Lighting.Brick | local brick = game.Lighting.Brick | ||
local cam = game.Workspace.CurrentCamera | |||
local brickClone = brick:clone() | |||
brickClone.Parent = cam | |||
</syntaxhighlight> | |||
</ | |||
==The Code== | ==The Code== | ||
Line 109: | 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. | ||
=Other Ideas That You Could Do= | =Other Ideas That You Could Do= | ||
Line 122: | 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;"> | <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
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: