a = script.Parent
cd = a.coredetails
color = cd.partcolorval
gui = cd.gui
a.Equipped:Connect(function()
gui.Parent = game.Players.LocalPlayer.PlayerGui
end)
a.Unequipped:Connect(function()
gui.Parent = cd
end)
a.Activated:Connect(function()
local m = game.Players.LocalPlayer:GetMouse()
local target = m.Target
if target == nil then return end
gui.colorthing.Text = "Color: "..target.BrickColor
end)
✓ ANSWER ACCEPTED
what is userdata value and how to fix it??????
1 answer
✓ Accepted answer
target could be something else other than a Part so maybe you should check for that.
The reason for the error is that you are trying to print
BrickColorwhich 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:
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
1 comment
0
thank u very much
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
note: im did this local script in tool
This isn't an answer but you don't need to get the mouse every time you activate it. Put m variable at line 5
at what line did you get the userdata error?
a UserData is a most often, roblox object