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

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


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.

3 comments

0

It won't affect anything.

0

It does that because you can't put spaces like this: workspace.Existing 1

0

br0

1 answer

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.

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