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

Is it better to use tostring() or Instance.Name?

Asked by 5 years ago

Just to get the best practice possible, but let's say I would like to make "Part" a variable, is it best to do local Part = Part.Name or local Part = tostring(Part)?

3
part.Name. User#19524 175 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

.Name. tostring isn't necessary in most cases. They both work, however.

Ad
Log in to vote
1
Answered by 5 years ago

Generally i would prefer to use Part.Name instead of tostring(Part) for the same reason people use fori,v in in next, tbl do instead of for i,v in pairs(tbl). The reason is that Part.Name is shorter than tostring(Part), by 4 characters.

The second reason that I recommend Part.Name instead of tostring(Part) is because Part.Name makes a bit more sense than tostring(Part) . For Part.Name gets the name property of the part, and tostring(Part) converts an object into a string

0
Damn I want to accept this but I read the first one and did that sorry man Marmalados 193 — 5y

Answer this question