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

How do I make a dance floor with specific colours?

Asked by 4 years ago

How do I make a dance floor with specific colours? Here's my attempt:

 local colours = {
            "Really blue",
            "Deep orange",
            "New Yeller",
            "Bright green",
            "Really blue", 
            "Cyan",
            "Carnation pink", 
            "Eggplant",
            "White"
        }               

        local randomColour = math.random(1,#colours)
        local Parts = game.Workspace.GameParts.unsafeParts:GetChildren()

        while true do
            for i,v in pairs(Parts) do
                if v:IsA("Part") then
                    v.BrickColor = BrickColor.new(colours[randomColour])
                end
            end
        wait(4)
    end
0
Why not use BrickColor.random Pupppy44 671 — 4y
0
ok ill try and test CHEESEPIZZAPARTYTIME 5 — 4y

2 answers

Log in to vote
0
Answered by
Pupppy44 671 Moderation Voter
4 years ago
Edited 4 years ago

Edited mines*

local Parts = game.Workspace.GameParts.unsafeParts:GetChildren()
local Colors = {
"Really red",
"Bright yellow",
"Bright blue"
}

while wait(4) do -- You can also do this for waiting
           for i,v in pairs(Parts) do
               if v:IsA("Part") then
        local Num = math.random(1, #Colors) -- Get a random number between 1 and the number of strings in colors
                   v.BrickColor = BrickColor.new(Colors[Num]) -- So if Num == 2, then it would change to bright yellow
               end
           end
   end

Hope this helps!

0
Yeah but I want to use specific colours, not any random colour TheObviousNinja 19 — 4y
0
I edited mines, you can retry it. Pupppy44 671 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Alternatively, you could do this:

local colors = {
    BrickColor.new("Tawny"),
    BrickColor.new("Toothpaste"),
    BrickColor.new("Teal"),
    BrickColor.new("Terra Cotta"),
    BrickColor.new("Steel blue"),
}

local randomcolor = colors[math.random(1,#colors)]

local part = game.Workspace.Part
part.BrickColor = randomcolor

local Parts = game.Workspace.GameParts.unsafeParts:GetChildren()

while true do
    for i,v in pairs(Parts) do
        if v:IsA("Part") then
            v.BrickColor = BrickColor.new(colours[randomColour])
        end
    end
    wait(4)
end

Answer this question