Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this BrickColorValue not work?

Asked by 9 years ago

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

Log in to vote
1
Answered by 9 years ago

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

0
Ahh. Okay! I'll keep this in mind! Thanks! minikitkat 687 — 9y
0
No problem FearMeIAmLag 1161 — 9y
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` BlueTaslem 18071 — 9y
0
It worked and the guy was happy so there is no need to be fickle over the details. FearMeIAmLag 1161 — 9y
Ad

Answer this question