#Randomize Color Sequence in Script

1 messages · Page 1 of 1 (latest)

cerulean swan
#

Hello, I am a beginner scripter on Roblox Studio, and this is one of my first "proper" scripts I made from learning a few bits of scripting from YouTube tutorials (and the forums too). Here is a script for a basic color-changing part I made by myself. The question in mind is on how do I randomize the colors in the script so that I could make a basic dance floor without having to change the color sequences in each part individually. Yes, the script does work, but I want to randomize the color sequences because I don't know how.

local Rainbow = script.Parent

task.wait(3)

Rainbow.Material = "Neon"

print("Neon material has been successfully applied.")

task.wait(3)

print("Executing RGB sequence...")

task.wait(3)

while true do
    Rainbow.BrickColor = BrickColor.new "Really red"
    task.wait(1)
    Rainbow.BrickColor = BrickColor.new "Bright orange"
    task.wait(1)
    Rainbow.BrickColor = BrickColor.new "New Yeller"
    task.wait(1)
    Rainbow.BrickColor = BrickColor.new "Lime green"
    task.wait(1)
    Rainbow.BrickColor = BrickColor.new "Cyan"
    task.wait(1)
    Rainbow.BrickColor = BrickColor.new "Magenta"
    task.wait(1)
end
idle ermine
#

You could add all the colors to a table and then grab a random color from the table

#

something like this


local Part = Instance.new("Part", workspace)

local Colors = {
    BrickColor.new("New Yeller"),
    BrickColor.new("Lime green"),
    BrickColor.new("Really red")
}


while true do
    task.wait(.5)
    
    local NewColor = Colors[math.random(1, #Colors)]
    print(NewColor)
    Part.BrickColor = NewColor
end
#

although personally, I don't like using BrickColor as much as using Color3

#

just allows you to use more personalized colors

lime hamlet
#

yes, try

RandomColor3 = Color3.new(math.random(1,255),math.random(1,255),math.random(1,255))
idle ermine
# cerulean swan where do i put that in?
local Part = Instance.new("Part", workspace)



while true do
    task.wait(.2)
    local NewColor = Color3.new(math.random(1,255),math.random(1,255),math.random(1,255))
    Part.Color = NewColor
end
#

its way simpler

#

and can give you any color

#

but some of the colors are a little more dull or unsightly so you might need to add params

cerulean swan
#

I'll learn more about math, parameters and returns soon

#

haven't watched a tutorial on that yet