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

How to recognize a model with spaces?

Asked by 10 years ago

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

How can I fix this?

Thank you.

0
Can you provide the code you used, please? :) TheeDeathCaster 2368 — 10y

2 answers

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

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
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"]`) BlueTaslem 18071 — 10y
Ad
Log in to vote
-2
Answered by 10 years ago

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

0
This is actually grossy inefficient compared to directly accessing the Object using the brackets. adark 5487 — 10y

Answer this question