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

help with color3?

I have been making a Gui that can be used to change the material and color of a selected brick. so far,the material and selection systems work perfectly, but the color system is not working due to some trouble with color3 values. here is the code so far:

script.Parent.MouseButton1Click:connect(function()
bases=script.Parent.Parent.Parent.BaseColors:GetChildren()
number=string.match(script.Parent.Name,"%d")
color=bases[tonumber(number)].Value--last 3 lines find the value containing the color3value
print(color.r/255,color.g/255,color.b/255)--prints 0.0013071895814409 0.003921568627451 0 for 85, 255, 0


script.Parent.Parent.Parent.Parent.Parent.SelectedItem.Value.BrickColor=BrickColor.new(color.r/255,color.g/255,color.b/255)--tries to set the color of the selected part to the selected color,
--but it will set it to the output mentioned above
end)

any ideas guys? thanks in advance!

1 answer

You can set the part's color with Color3 as well, it will just automatically find the closest preset color from BrickColors.

script.Parent.MouseButton1Click:connect(function()
	bases = script.Parent.Parent.Parent.BaseColors:GetChildren()
	number = string.match(script.Parent.Name,"%d")
	color = bases[tonumber(number)].Value
	print(color.r/255,color.g/255,color.b/255)

	script.Parent.Parent.Parent.Parent.Parent.SelectedItem.Value.Color = Color3.new( color.r/255, color.g/255, color.b/255 )
end)

Edit: Fixed the color systems

2 comments

0

yes but it matches it to the 0-1 format, not the 0-255 format and sets the brick to black

0

Right, still same logic applies

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