Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do I Set Something To A Brick That Has A Name Of Two Words?

Asked by
Scootakip 299 Moderation Voter
9 years ago

I know that the title is kinda a confusing mess because I don't know how to title this, but I might be more clear here.

local ll = h.Parent.Left

I want to make local ll assigned to the Left Leg of the character but I don't know how to write Left Leg in the script because of the space in between Left and Leg. Can someone help me with this?

0
h.Parent:FindFirstChild("Left Leg") :D pluginfactory 463 — 9y

2 answers

Log in to vote
8
Answered by 9 years ago

If you know for a fact the object exists, you can use square brackets followed by a string value containing it's name (you can also index tables this way)

For example:

local Part = workspace["Part with spaces in name"]

FindFirstChild also works, but shouldn't really be used to just get something with spaces in the name. However, you should use this a lot if you don't know for certain it exists, because this can prevent your script from breaking. You can use it by calling it as a method on the object you're searching the object for:

local Part = workspace:FindFirstChild("Part with spaces in name")

Now, FindFirstChild is a function, so we can actually call it multiple ways. You've probably seen something like this before:

local Something = workspace:FindFirstChild("Part with spaces in name")

local Something2 = workspace:FindFirstChild"Part with spaces in name"

local Something3 = workspace:FindFirstChild'Part with spaces in name'

However, I'm not going to make this a answer about functions. Just thought that'd be some useful information, hope it helped.

Ad
Log in to vote
-2
Answered by
Udrii 0
9 years ago
local ll = h.Parent:FindFirstChild("Left Leg")
0
:P Orely. pluginfactory 463 — 9y

Answer this question