Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

1 comment

0

h.Parent:FindFirstChild("Left Leg") :D

2 answers

✓ Accepted answer

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.

local ll = h.Parent:FindFirstChild("Left Leg")

1 comment

0

:P Orely.

This discussion is preserved as it was. New answers, comments, and votes are closed.