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

help with color3?

Asked by
lukeb50 631 Moderation Voter
8 years ago

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

Log in to vote
0
Answered by 8 years ago

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

0
yes but it matches it to the 0-1 format, not the 0-255 format and sets the brick to black lukeb50 631 — 8y
0
Right, still same logic applies ZarsBranchkin 885 — 8y
Ad

Answer this question