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

How to Make A Variable For Something With a Space?

Hello, I am trying to make a variable for the players Left Arm, found under character. I tried using FindFirstChild and WaitForChild and still got nothing when I tried to print the Parent. Here are the scripts:

Players = game:GetService("Players")
player = Players.LocalPlayer
char = player.Character
larm = char:FindFirstChild("Left Arm")
print(larm.Parent)

The other script is the same expect for WaitForChild being there instead of FindFirstChild. Thanks for reading!

3 comments

1

Try "larm = char["Left Arm"]".

0

It worked! Thanks!

0

Np.

1 answer

✓ Accepted answer

When you see something like obj.property, that is sugar for using table-indexing with []:

obj.property is exactly the same thing as obj["property"].


Thus, you could use either char.Head or char["Head"].

While you can't use char.Left Arm, since a string literal can have spaces in it, you can use char["Left Arm"].

1 comment

0

Thank you for the explanation!

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