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

How to recognize a model with spaces?

My script can't recognize a model with spaces in its name.

How can I fix this?

Thank you.

1 comment

0

Can you provide the code you used, please? :)

2 answers

I assume you mean "access", not recognize, in which case you'll need to use bracket access notation:

workspace["Part name With Spaces!"]

Inside the brackets can be anything that eventually evaluates to be a string (i.e. a function call or a concatenation), which is incredibly useful:

local index = 5
workspace.Rooms["Room:" .. index]

1 comment

1

A point I like to make is that this works with normal names, too, and that it's also how . works (workspace.Rooms is the same as workspace["Rooms"])

You could also say it as a string, like or playerName == "Stealth Pilot" That works too, and it's a bit less messy than brackets all over if you're making a really long script

1 comment

0

This is actually grossy inefficient compared to directly accessing the Object using the brackets.

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