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

How to put a part's BrickColor in a Text Label?

Hello, I recently created a script in a tool that identifies the BrickColor of a certain part and prints it in the output, however, I don't know how to put it in the text label so that it displays it in a Gui. I'm sorry for bad grammar, im not a fluent english speaker.

Here is the script i am currently working with:

local g
script.Parent.Equipped:connect(function(mouse)
	g = script.ToolGui2:Clone()
	g.Parent = game:GetService("Players").LocalPlayer.PlayerGui
	g.Frame.Frame.TextLabel.Text = ""
	mouse.Move:connect(function()
		local targ = mouse.Target
		if targ then
				g.Frame.Frame.TextLabel.Text = "[Insert BrickColor here]"
				print(targ.BrickColor)
		end
	end)
end)
script.Parent.Unequipped:connect(function()
	if g then g:Destroy() end
end)

2 comments

0

Were it says g.Frame.Frame.TextLabel.Text = "[Insert BrickColor here]" change the [Insert BrickColor here] to targ.BrickColor

0

Well it changes the text into targ.BrickColor but not the BrickColor of the part itself

1 answer

local g
script.Parent.Equipped:connect(function(mouse)
    g = script.ToolGui2:Clone()
    g.Parent = game:GetService("Players").LocalPlayer.PlayerGui
    g.Frame.Frame.TextLabel.Text = ""
    mouse.Move:connect(function()
        local targ = mouse.Target
        if targ then
                g.Frame.Frame.TextLabel.Text = tostring(targ.BrickColor) --makes the BrickColor into a string value
                print(tostring(targ.BrickColor))
        end
    end)
end)
script.Parent.Unequipped:connect(function()
    if g then g:Destroy() end
end)

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