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

Message text not saying part BrickColor?

Asked by 8 years ago

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
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. M39a9am3R 3210 — 8y
1
I see now thanks! ambu123 5 — 8y

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

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

Ad

Answer this question