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

Why is this color3 so badly made? why does it print so much random stuff and not work?

Asked by 4 years ago

ok so, i have some BADLY written code that i need some coding guru to take a look at!! I just don't understand why my gui textbuttons color keeps showing up black... Like even though i like black stuff, I don't understand why its not some other color, here is my pathetic code..

(Dont worry about the variables and all)

for _, v in pairs(game.ReplicatedStorage.Shop_Items:WaitForChild(typeC):GetChildren()) do
        local new = game.ReplicatedStorage.Shop_Items.Default_Button:Clone()
        new.Parent = Main.Purchase_Chest.Main
        new.Name = v.Name
        new.Text = v.Name
        local obj = game.ReplicatedStorage.Shop_Items:WaitForChild(typeC):FindFirstChild(v.Name)
        print(obj.Color)
        new.BackgroundColor3 = Color3.new(obj.Color)
    end

it all works except the background color doesnt change to the other color

example:

local color = workspace.Part

gui.BackgroundColor3 = Color3.new(color.Color)

In the example above i try changing the background color to whatever the parts color is but it will forever show up black, I will never understand it, help please. thx

1 answer

Log in to vote
0
Answered by 4 years ago

It shows up as black because it's an invalid color.

Solution

Your code

local color = workspace.Part

gui.BackgroundColor3 = Color3.new(color.Color) --color.Color is already a color3 value

What it should be

local color = workspace.Part

gui.BackgroundColor3 = color.Color

Color3.fromRGB()

If you further set colors of things, I suggest you use Color3.fromRGB() because it makes sense. Color3.new() uses values from 0 to 1 where Color3.fromRGB() uses values from 0 to 255.

gui.BackgroundColor3 = Color3.new(100/255, 100/255, 100/255)
gui.BackgroundColor3 = Color3.fromRGB(100, 100, 100)
0
tried thta ^_^ greatneil80 2647 — 4y
0
i noticed it prints colors like 0 1 0 1 0 0 1 greatneil80 2647 — 4y
0
It's working fine for me, I just tested it in studio? PhantomVisual 992 — 4y
0
remember i have to set it to another color3, i cant use numbers... greatneil80 2647 — 4y
View all comments (3 more)
0
I don't understand. Are you setting a GUI's color to match a part's color or is it more than that? What is the "obj" variable's class? PhantomVisual 992 — 4y
0
obj is a particle emitter, I am trying to set a gui color to a particles color greatneil80 2647 — 4y
0
Particle emitters are a color sequence. Use ColorSequence.new() to do it. https://developer.roblox.com/api-reference/datatype/ColorSequence PhantomVisual 992 — 4y
Ad

Answer this question