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

what is userdata value and how to fix it??????

Asked by 5 years ago
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)
0
note: im did this local script in tool MissingBoshjio 22 — 5y
0
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 Jack_Hase 85 — 5y
0
at what line did you get the userdata error? RedWirePlatinum 53 — 5y
0
a UserData is a most often, roblox object theking48989987 2147 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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:

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

0
thank u very much MissingBoshjio 22 — 5y
Ad

Answer this question