Simple conditional statement returning the wrong BrickColor

Hi, so this is literally one of line code. For whatever reason, it’s returning the value of Medium stone grey…does anybody know why??

local color_v = (bomb.Name == "Kill Bomb" and BrickColor.new("Bright red")) or BrickColor.new("Pastel blue")

Thanks.

What are you expecting it to return?

1 Like

It should be returning either Bright red or Pastel blue, but for whatever reason I’m getting Medium stone grey…

actually makes no sense.

You have

bomb.Name == "Kill Bomb" and BrickColor.new("Bright red")

?

1 Like

Yeah. If the bomb is a Kill Bomb, make a red explosion. If not, make it a blue one.

It should be BrickColor.new(“Pastel Blue”)

The B should be capitalized.

3 Likes

Ah you’re correct. Thank you, and I assume the reason for the Medium stone grey is because that’s what it returns if you attempt to create a BrickColor that doesn’t exist.

I also just found out the condition

bomb.Name == "Kill Bomb"

Is never true, so I gotta fix that up.

Thanks guys!

1 Like

If you’re interested in a (possibly) more clear way to write your code, you can actually determine the string inside the new constructor instead of constructing a new object based on the bomb’s name.

local color_v = BrickColor.new(bomb.Name == "Kill Bomb" and "Bright red" or "Pastel Blue")
5 Likes