|
| 13 Sep 2013 03:56 PM |
How do you find an object that has a space in it?
Example:
game.Workspace.Player.Left Arm:Destroy()
It won't find 'Left Arm'.. I used to know this but my absence from Roblox has sort of erased part of my scripting knowledge. |
|
|
| Report Abuse |
|
|
Absurdism
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 2568 |
|
|
| 13 Sep 2013 03:56 PM |
Brackets.
Workspace.Player['Left Arm']:Destroy() |
|
|
| Report Abuse |
|
|
|
| 13 Sep 2013 03:57 PM |
@Ab
Ohh-
I was doing ["Left Arm"].. Thanks! |
|
|
| Report Abuse |
|
|
|
| 13 Sep 2013 03:58 PM |
| The line still has a red bar underneath it though.. |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 13 Sep 2013 03:59 PM |
It doesn't matter whatever you use ' or ". The problem must've been something else, jojo.
- As, Well, it only matters if you have quotes inside a string. Or something like that. [[Helooh]] |
|
|
| Report Abuse |
|
|
|
| 13 Sep 2013 04:00 PM |
Hmm.
game.Workspace.MangoStudio.['Right Arm'].Color = BrickColor.new("Black")
It is underlining this red. :( |
|
|
| Report Abuse |
|
|
|
| 13 Sep 2013 04:01 PM |
Local player = game.Players.LocalPlayer LeftArm = player.Character.["Left Arm"] game.Workspace.Player.LeftArm:Destroy() |
|
|
| Report Abuse |
|
|
|
| 13 Sep 2013 04:02 PM |
@thekiller
It still underlines it red. |
|
|
| Report Abuse |
|
|
| |
|
|
| 13 Sep 2013 04:05 PM |
The output states-
Workspace.Script:43: name expected near [ |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 13 Sep 2013 04:08 PM |
The problem is your .
Look, when using brackets, dots are only found AFTER the brackets... amazingly enough.
workspace["Name"] = "Hello" -- will change the name of Workspace to Hello.
workspace["Part"].BrickColor = BrickColor.new("White") -- Will change the brickcolor of Part to White.
Also, you can do the same stuff with tables as with instances. Those tables are called dictionaries.
local tab = {a = 1, b = 2, [workspace] = 3, ["c"] = 4}
print(tab.a) > 1 print(tab["b"]) > 2 print(tab.c) > 4 print(tab[workspace]) > 3 -- Note that at step 4, the brackets are required, because our key is an instance, not a string.
- As, NOW, METATABLES DEWD! |
|
|
| Report Abuse |
|
|
Absurdism
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 2568 |
|
|
| 13 Sep 2013 04:08 PM |
Details are important. I didn't put a period before the brackets. Also, the syntax of the quotes don't matter. It could be denominated as "", '', [[]]. [==[]==], so on.
game.Workspace.MangoStudio['Right Arm'].Color = BrickColor.new("Black") |
|
|
| Report Abuse |
|
|
|
| 13 Sep 2013 04:09 PM |
@as
Wow I didn't know that! Thanks a lot. :D |
|
|
| Report Abuse |
|
|