A Roblox Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeLatest imagesRegisterLog in
If you're a experienced coder make some tutorials! It would really help the site grow.
Make sure you read the rules(Which can be found by clicking here)
If you're a beginner at coding, try some tutorials.
We have many Moderators/Admins watching this site. Contact them with Questions.
Let us know what your favorite sport is. By clicking here to vote (Click here)
This site is becoming inactive. Lets make it active.
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Top posters
blueymaddog
LocalParts Vote_lcapLocalParts Voting_barLocalParts Vote_rcap 
naknak
LocalParts Vote_lcapLocalParts Voting_barLocalParts Vote_rcap 
Supernapalm
LocalParts Vote_lcapLocalParts Voting_barLocalParts Vote_rcap 
m27frogy
LocalParts Vote_lcapLocalParts Voting_barLocalParts Vote_rcap 
slayer9365
LocalParts Vote_lcapLocalParts Voting_barLocalParts Vote_rcap 
myrco919
LocalParts Vote_lcapLocalParts Voting_barLocalParts Vote_rcap 
branefreez
LocalParts Vote_lcapLocalParts Voting_barLocalParts Vote_rcap 
ninga95
LocalParts Vote_lcapLocalParts Voting_barLocalParts Vote_rcap 
CloneTrooper787
LocalParts Vote_lcapLocalParts Voting_barLocalParts Vote_rcap 
raboy117
LocalParts Vote_lcapLocalParts Voting_barLocalParts Vote_rcap 
Top posting users this month
No user
Latest topics
» Where to go from here.
LocalParts EmptySeptember 14th 2020, 1:20 pm by MrNicNac

» Send me an Email
LocalParts EmptySeptember 14th 2020, 1:16 pm by MrNicNac

» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]
LocalParts EmptyJuly 6th 2015, 7:38 pm by m27frogy

» New Site Possibly
LocalParts EmptyJuly 6th 2015, 4:16 pm by m27frogy

» Ambassador!
LocalParts EmptyApril 15th 2015, 11:40 pm by naknak

» Boop - Tag
LocalParts EmptyApril 13th 2015, 9:46 pm by naknak

» Vip Class Script
LocalParts EmptyApril 13th 2015, 4:54 pm by naknak

» Who's active?!
LocalParts EmptyApril 13th 2015, 4:52 pm by naknak

» Genesis Point
LocalParts EmptyJuly 17th 2014, 7:04 pm by branefreez

» Reward System
LocalParts EmptyJuly 17th 2014, 5:41 am by m27frogy

» Script Request
LocalParts EmptyJuly 10th 2014, 11:43 am by naknak

» local scripts?
LocalParts EmptyJuly 10th 2014, 11:39 am by naknak

» Project: Reconstruction [Died]
LocalParts EmptyJuly 10th 2014, 11:36 am by naknak

» Hi. I am new here
LocalParts EmptyApril 26th 2014, 4:01 pm by altshiftkey

» What's your favorite sport?
LocalParts EmptyJanuary 1st 2014, 2:13 pm by m27frogy

» FlashLight Script
LocalParts EmptyJanuary 1st 2014, 2:11 pm by m27frogy

» Gun Making! [READ DESC]
LocalParts EmptyJanuary 1st 2014, 2:10 pm by m27frogy

» Hi, I am new here!
LocalParts EmptyNovember 26th 2013, 3:33 pm by Keanu73

» Improve Coding
LocalParts EmptyOctober 26th 2013, 1:12 pm by pook03

» Simple Button
LocalParts EmptySeptember 1st 2013, 6:19 pm by branefreez


 

 LocalParts

Go down 
2 posters
AuthorMessage
Guest
Guest
avatar



LocalParts Empty
PostSubject: LocalParts   LocalParts EmptyAugust 8th 2010, 9:01 pm

Okay, a LocalPart is a part that only one player can see. (This is going to be annoying to make super simple...) These parts MUST be created using ONLY a LocalScript. To avoid annoying-to-edit spaghetti (really messy) code, I suggest building the object where you like it, then placing it into the Lighting service. Then just clone it. Anyways, you need to use a LocalScript, meaning you can place it in either the StarterPack or the StarterGear, so it will always go into the player in some way. Or you can always clone it in, but that isn't fun. Now, time to script. LocalParts need to be placed into the CurrentCamera object in Workspace. This is why a LocalScript is needed. To access the camera, you need the LocalScript. That is the only reason for it.
Spoiler:
Now, (if you read the spoiler, you would know why I said now) With LocalParts, though, the touched event will NOT work. Instead you need a different event, named .LocalSimulationTouched. This event works like .Touched, though, it only works for LocalParts, and it only works for the player the LocalPart belongs to. (I'm getting bored about now...) So, time for code. In this example, there will be a model in Lighting named LOCAL_TEST. This model will be cloned into the CurrentCamera. In the model will be a part named Button. When this is touched, a message will appear.

Code:
local Model = game.Lighting.LOCAL_TEST:Clone()
Model.Parent = game.Workspace.CurrentCamera

In this, we took LOCAL_TEST and created a copy of it, then we placed it into the CurrentCamera. Now, we need to create a LocalSimulationTouched event for the Button. For this we will use an annoymous function, which has no name to it. The connection also comes BEFORE the function, rather than after. If you become advanced later on, you will learn to love these =P

Code:
Model.Button.LocalSimulationTouched:connect(function(Hit)

This creates the event. Now to make a message in the player. We will set the text as "You have touched a LocalPart". Then we will remove the Part. Now, there are two ways to set an Instance'd object. The first is a simpler way. The second is faster and shorter, though. I will add the second way in comments, though, the first way will be the way run.

Code:
local Message = Instance.new("Message")
--local Message = Instance.new("Message", game.Players.LocalPlayer)
--Now, this way, the parent becomes the second argument of the function.
--It is more advanced, kinda. You don't need to set .Parent,
--using this, though
Message.Parent = game.Players.LocalPlayer
Message.Text = "You have touched a LocalPart"
wait(3) --Wait 3  seconds
Message:Remove() --Remove the message
Model.Button:Remove() --Remove the button
end) --End the function

Now, that is the script. In chunks. We can make it all together, and it will look a little different. Though, then you can just copy and paste it and use the same model instructions as the example. Then you learn nothing. So, I will place it in a spoiler, if you read this, you will know that.
Spoiler:



**PLEASE INFORM ME OF ALL ERRORS IN THIS IF ANY**
Back to top Go down
Prodigy
Administrator
Administrator
avatar


Posts : 58
Join date : 2010-07-28

LocalParts Empty
PostSubject: Great tutorial   LocalParts EmptyAugust 8th 2010, 9:56 pm

This is a great tutorial and will come in handy for many different things. The main use for this tutorial would probably be a question/quiz game.
Back to top Go down
http://roblox.forumclan.com
Guest
Guest
avatar



LocalParts Empty
PostSubject: Re: LocalParts   LocalParts EmptyAugust 8th 2010, 10:03 pm

I feel my commentry is all in order :3
Back to top Go down
Guest
Guest
avatar



LocalParts Empty
PostSubject: Re: LocalParts   LocalParts EmptyAugust 9th 2010, 12:24 am

Prodigy wrote:
This is a great tutorial and will come in handy for many different things. The main use for this tutorial would probably be a question/quiz game.
I actually based a game section around this. I used LocalParts to make my doors (well, gates) to lock a LongBow in a cage. Then when you press a LocalButton, it opens the gate.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 26

LocalParts Empty
PostSubject: Re: LocalParts   LocalParts EmptyJanuary 18th 2011, 8:15 am

Nice tutorial! almost belongs to intermediate tutorials.
Back to top Go down
Sponsored content





LocalParts Empty
PostSubject: Re: LocalParts   LocalParts Empty

Back to top Go down
 
LocalParts
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
A Roblox Community :: Tutorials and Resources :: Beginner-
Jump to: