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

How to Make A Variable For Something With a Space?

Asked by 8 years ago

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!

1
Try "larm = char["Left Arm"]". ISellCows 2 — 8y
0
It worked! Thanks! yoman1776 85 — 8y
0
Np. ISellCows 2 — 8y

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
8 years ago

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"].

0
Thank you for the explanation! yoman1776 85 — 8y
Ad

Answer this question