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

Message text not saying part BrickColor?

The line of code that says "msg.Text = ("The part color isn't bright blue it is" .. part.BrickColor)" won't work, the output says "attempt to concatenate field 'BrickColor' (a userdata value)" what does that mean help!?

local part = workspace.Part 
part.Touched:connect(function(touch) 
local msg = Instance.new("Message", workspace) 
part.BrickColor = BrickColor.Random() 
if part.BrickColor == BrickColor.new("Bright blue") then 
msg.Text = ("The part color is now bright blue") 
else 
msg.Text = ("The part color isn't bright blue it is" .. part.BrickColor) 
end 
end)

2 comments

2

Since Concatenation can only work on strings and numbers, you need to convert the part.BrickColor value to a string. This can easily be done with BrickColors as they have a little addon, I guess you could say, which is .Name. All you have to do is add .Name to the end of .BrickColor on line 8.

1

I see now thanks!

1 answer

part.BrickColor is not a string, but it does have a Name value, so writing part.BrickColor.Name will solve the issue.

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