How to make it so this script makes every "flower" a unique colour instead of changing every single one to the same colour

title says it all

ive tried everything but it wont work

local colour = BrickColor.Random()

for _,v in ipairs(script.Parent.Models:GetDescendants()) do
	if v.Name == "Petal" then
		v.BrickColor = colour
	end
end

also i meant flower how do i make it so every flower is a different kind of colour sorry

1 Like
for _,v in ipairs(script.Parent.Models:GetDescendants()) do
	if v.Name == "Petal" then
		v.BrickColor = BrickColor.Random()
	end
end

Call the random brick color inside of the loop instead of defining one and then setting all of the petals to it, like this:

for _,v in ipairs(script.Parent.Models:GetDescendants()) do
	if v.Name == "Petal" then
		v.BrickColor = BrickColor.Random()
	end
end

how do i make every petal the same colour and make it randomize the colour again when it moves onto the next “flower” sorry lol

Sorry, I am having trouble understanding what you mean, could you elaborate more into detail about what you’re trying to achieve?

like i want every flower in a folder to be a random colour, so how would i do that lol

If you have different multiple fields of the same petal under one folder, you could do something like this:

for _,field:Folder in ipairs(script.Parent.Models:GetChildren()) do -- getting only the children aka the folders of the petals, considering there are only folders under the Model object

    -- now, we are looping through the different folders (representing fields) so we can get the one desired random color for the field

    local color = BrickColor.Random()

    -- now we just loop through the petals in this field and apply the color to all of them

    for i, petal in pairs(field:GetDescendants) do
        
        if petal.Name == "Petal" then
            petal.BrickColor = color
        end

    end

end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.