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

Why does it do ["This"] whenever I have a space in the name of a part in the workspace?

Asked by 3 years ago

script.Parent.Touched:Connect(function(p) if p.Parent:FindFirstChild("Humanoid")then p.Parent.Humanoid.WalkSpeed = 0 end workspace["Existing 1"] end)

Whenever I name something in workspace that has a space in it it highlights it in a script with something like ["This"] and I cannot really continue coding after that because it wont connect.

Be aware I am new to Lua.

0
It won't affect anything. 0Papa_Rat0 63 — 3y
0
It does that because you can't put spaces like this: workspace.Existing 1 0Papa_Rat0 63 — 3y
0
br0 Gey4Jesus69 2705 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

This is simply how you approach the ObjectValue of an instance with whitespace in its name. For example, if I have a part in the workspace named Test Part, to get the ObjectValue of the instance, we write workspace["Test Part"]

Attempting to write it another way, such as workspace.Test Part will error.

Thus, in your case, let's say you wanted to change the Name of the Existing 1 instance in your game. We can write `workspace["Existing 1"].Name = "New Name"

Let me know if you have any further questions.

Ad

Answer this question