Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this BrickColorValue not work?

Hello! So yeah, I stumbled across another problem in my script that I have no idea what is wrong with it. So I want my BrickColorValue to be changed every second. (Don't ask why, it is complicated) But when ever I try to change it, nothing happens and it basically disables the script. (None of the other things in the script works.) There is nothing in the output so I have no idea whats wrong.

Tool = script.Parent
Value = Tool.BrickColorValue.Value

while true do wait()
	Value = BrickColor.new("Bright red")
		wait(1)
	Value = BrickColor.new("Toothpaste")
		wait(1)
	Value = BrickColor.new("Lime green")
		wait(1)
	Value = BrickColor.new("Mid gray")
		wait(1)
	Value = BrickColor.new("Bright violet")
		wait(1)
	Value = BrickColor.new("Bright yellow")
		wait(1)
	Value = BrickColor.new("Bright orange")
		wait(1)
end

1 answer

✓ Accepted answer

You can't set a variable equal to a property value as it does not work like that. I have fixed the script for you and it should work now. If you have any other questions or there is an issue, please let me know.

Tool = script.Parent
Val = Tool.BrickColorValue

while true do wait()
	Val.Value = BrickColor.new("Bright red")
	wait(1)
	Val.Value = BrickColor.new("Toothpaste")
	wait(1)
	Val.Value = BrickColor.new("Lime green")
	wait(1)
	Val.Value = BrickColor.new("Mid gray")
	wait(1)
	Val.Value = BrickColor.new("Bright violet")
	wait(1)
	Val.Value = BrickColor.new("Bright yellow")
	wait(1)
	Val.Value = BrickColor.new("Bright orange")
	wait(1)
end

Also, if you wanted to make the script shorter, you could place the values in a table and iterate over the table. Just a recommendation. This is how you would accomplish such a task:

Tool = script.Parent
Val = Tool.BrickColorValue

colors = {"Bright red", "Toothpaste", "Lime green", "Mid gray", "Bright violet", "Bright yellow", "Bright orange"}

while true do wait()
	for i,v in pairs(colors) do
		wait(1)
		Val.Value = BrickColor.new(colors[i])
	end
end

4 comments

0

Ahh. Okay! I'll keep this in mind! Thanks!

0

No problem

0

There's no point to saying colors[i] when you have v already! That said, you should probably use _, color so that you have clear variable names! Also a note that pairs won't return things in any particular order. If you need the order to be what you wrote, you have to use ipairs

0

It worked and the guy was happy so there is no need to be fickle over the details.

This discussion is preserved as it was. New answers, comments, and votes are closed.