01 | a = script.Parent |
02 | cd = a.coredetails |
03 | color = cd.partcolorval |
04 | gui = cd.gui |
05 |
06 | a.Equipped:Connect( function () |
07 | gui.Parent = game.Players.LocalPlayer.PlayerGui |
08 | end ) |
09 |
10 | a.Unequipped:Connect( function () |
11 | gui.Parent = cd |
12 | end ) |
13 |
14 | a.Activated:Connect( function () |
15 | local m = game.Players.LocalPlayer:GetMouse() |
16 | local target = m.Target |
17 | if target = = nil then return end |
18 | gui.colorthing.Text = "Color: " ..target.BrickColor |
19 | end ) |
1) target could be something else other than a Part so maybe you should check for that.
2) The reason for the error is that you are trying to print BrickColor
which is a userdata, usually it would get turned into a string but it doesn't for some reason now that it has some other string with it.
so all you have to do is:
1 | gui.colorthing.Text = "Color: " .. tostring (target.BrickColor) |
tostring() makes sure that what you are trying to join with that string is in fact a string as well
Tip: always use tostring() when joining to objects into one string