#What is the best way to change colour

21 messages · Page 1 of 1 (latest)

kindred creek
#

So I'm working on UI and I want it to change into different colours I'm going to use a repeat thing.

ancient fiber
#
-- using Quad UI Library to implement things
local ScreenGUI = script.Parent
local Quad = require(path.to.module).Init()
local Class,Mount,Store = Quad.Class,Quad.Mount,Quad.Store

local Frame = Class "Frame"

Frame "mainFrame" {
    Size = UDim2.fromScale(1,1);
    Frame "Child" {
        Size = UDim2.fromOffset(20,20);
    };
    Frame "Child" {
        Size = UDim2.fromOffset(20,20);
        Position = UDim2.fromOffset(30,0);
    };
    Frame "Child" {
        Size = UDim2.fromOffset(20,20);
        Position = UDim2.fromOffset(60,0);
    };
    Frame "Child" {
        Size = UDim2.fromOffset(20,20);
        Position = UDim2.fromOffset(90,0);
    };
}

Mount(ScreenGUI, Store.GetObject("mainFrame"))

Store.GetObjects("Child").Size = UDim2.fromOffset(30,30)

-- You can also use EachAsync(), IsEmpty()
task.spawn(function()
    while true do
        Store.GetObjects("Child"):Each(function (item, index)
            item.BackgroundColor3 = Color3.fromRGB(
                math.random(0,255),
                math.random(0,255),
                math.random(0,255)
            )
        end)
        task.wait(1)
    end)
end

-- using for loop to print every children of Child Tagged Objects
for _,child in ipairs(Store.GetObjects("Child")) do
    print(child)
end
ancient fiber
warm wagon
#

Ik i aint stupid

#

But so complex for it to change colors

ancient fiber
#

Quad Library can make your custom class and make synced functions to your class

#

It's so useful

#

For pro scripting

#

React - styled ui programming is the best practice for learning luau

weary phoenixBOT
#

studio** You are now Level 8! **studio

warm wagon
#
local colors = {Color3.fromRGB(65, 65, 65), "Add more colors!"}
local Gui = "UR GUI DIRECTORY"
local cooldown = 1 -Set the number of seconds it should wait before switching to another color.

while true do
Gui.Color = colors[math.random(1, #colors)]
wait(cooldown)
end
#

That does what is needed

#

And is way simpler to understand

ancient fiber
#

Yeah its simpler than my one but if you need 100 color-changing gui then you'd need 100 scripts

kindred creek
#

like im so lost lol

kindred creek
#

he means u have to put it in every gui a script