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

A simple question about the print function. Why does one work and the other doesn't?

How come this works...

print("The color is now", a.BrickColor)

and this does not?

print("The color is now  " .. a.BrickColor)

Just want to clear up my curiosity.

2 comments

0

Well, I think you might get an error saying Cannot concatenate BrickColor.

1

Exactly, that's the same error I'm getting.

1 answer

✓ Accepted answer

The .. operator is the string concatenation operator, meaning that it takes one string and joins it to another end to end. You are trying to concatenate a string to a BrickColor datatype, which has no direct conversion to string.

To concatenate the string and BrickColor properly, use the tostringfunction to convert the BrickColor to a string:

print("The color is now " .. tostring(a.BrickColor))

2 comments

1

So basically, the ".." operator only links strings together. And in order to link the string to the BrickColor datatype using the ".." operator, you must use the tostring function to change the BrickColor datatype to a string. Correct?

0

Right

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