colors = {
"Lime green",
"Hot pink",
"Really black",
"White",
"Teal",
}
while true do
script.Parent.BrickColor = BrickColor.new(math.random(1, #colors))
wait(1)
end
Why wont this table script work?
1 answer
You're asking the script to choose a random number between 1 and 5, but you're not using that number to do anything.
Let's say for example the random number it got was 3. If we put this into the script the way you have it set up, it would be like doing this:
script.Parent.BrickColor = BrickColor.new(3)
This is clearly incorrect, because 3 isn't the brickcolor.
To fix your script, we simply need to use the number we get to extract the corresponding string from the table. We'll do that like so:
script.Parent.BrickColor = BrickColor.new(colors[math.random(1, #colors)])
Now this would work correctly, and get the correct string from the table rather than a number. Your finished script should look like this:
colors = {
"Lime green",
"Hot pink",
"Really black",
"White",
"Teal",
}
while true do
script.Parent.BrickColor = BrickColor.new(colors[math.random(1, #colors)])
wait(1)
end
There you go! Anyways, I hope I helped. If you have any further problems/questions, please leave a comment below :P
####-Dyler3
This discussion is preserved as it was. New answers, comments, and votes are closed.
