I have a script that spawns objects, and I want them to be a different random color each time, but they all spawn as the same color. Here is the script:
local colors = {
BrickColor.new("Parsley green"),
BrickColor.new("Deep orange"),
BrickColor.new("Bright yellow"),
BrickColor.new("Neon orange"),
BrickColor.new("CGA brown"),
BrickColor.new("Mulberry"),
BrickColor.new("Sand green"),
BrickColor.new("Quill grey"),
BrickColor.new("Carnation pink"),
BrickColor.new("Bright orange"),
BrickColor.new("Dusty Rose"),
BrickColor.new("Cork")
}
while true do
local selectedSpillPoint = spillPoints[math.random(1,#spillPoints)]
local newSpillCFrame = selectedSpillPoint.CFrame
local spill = spillModel:Clone()
local spillOrientation = spill.Orientation
spill.Parent = game.Workspace
spill.CFrame = newSpillCFrame
spill.Orientation = spillOrientation
spill.BrickColor = colors[math.random(1,#colors)]
print("Spill made")
task.wait(10)
end
function PickColor(object)
local pickedColor = colors[math.random(1,#colors)]
object.BrickColor = pickedColor
end
while true do
local selectedSpillPoint = spillPoints[math.random(1,#spillPoints)]
local newSpillCFrame = selectedSpillPoint.CFrame
local spill = spillModel:Clone()
local spillOrientation = spill.Orientation
spill.Parent = game.Workspace
spill.CFrame = newSpillCFrame
spill.Orientation = spillOrientation
PickColor(spill)
print("Spill made")
task.wait(10)
end