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

Can a script detect if there is an error?

Asked by 9 years ago

So i'm making a GUI, and I am trying to make it check if the player entered a valid BrickColor value. Is there an easier way to do that than saying

if v==BrickColor.new("Really red") or v==BrickColor.new("Bright red") --etc.  etc.-- then

I know that if the player enters a wrong BrickColor, the script will obviously stack-end since it wont be a valid color.

NOTE v is defined

Here is the entire code:

script.Parent.MouseButton1Click:connect(function()
    v=script.Parent.Parent.Enter.Text

        game.Workspace.ColorBrick.BrickColor=BrickColor.new(v)

end)
0
You could create a table of all the brick colors. There might be a better way though. Perci1 4988 — 9y
0
Yeah, I am fairly certain there is an easier way. Tempestatem 884 — 9y

1 answer

Log in to vote
0
Answered by
TopDev 0
9 years ago

I honestly don't know any other way other than a table... but If you'd like here's a table of all of the brick colors

local BrickColors={
"Really black", 
"Black metallic", 
"Navy blue", 
"Really blue", 
"Deep blue", 
"Black", 
"Bright blue", 
"Dark Royal blue", 
"Earth green", 
"Earth blue", 
"Camo", 
"Dark green", 
"Cyan", 
"Bright bluish green", 
"Lime green", 
"Teal", 
"Toothpaste", 
"Medium lilac", 
"Royal purple", 
"Med. bluish green", 
"Royal blue", 
"Medium blue", 
"Tr. Green", 
"Bright bluish violet", 
"Dark grey metallic", 
"Dark stone grey", 
"Dark grey", 
"Medium Royal blue", 
"Bright green", 
"Faded green", 
"Earth yellow", 
"Sand green", 
"Dove blue", 
"Magenta", 
"Reddish brown", 
"Earth orange", 
"Alder", 
"Tr. Blue", 
"Bright violet", 
"Medium bluish violet", 
"Sand blue", 
"Pastel light blue", 
"Pastel blue-green", 
"Lilac", 
"Grime", 
"Lemon metalic", 
"Sand blue metallic", 
"Turquoise", 
"Dark red", 
"CGA brown", 
"Gun metallic", 
"Br. yellowish green", 
"Brown", 
"Bright reddish lilac", 
"Sand violet", 
"Lavender", 
"Bright reddish violet", 
"Rust", 
"Reddish lilac", 
"Sand red", 
"Silver flip/flop", 
"Pastel Blue", 
"Silver", 
"New Yeller", 
"Dusty Rose", 
"Red flip/flop", 
"Dark orange", 
"Sand yellow metallic", 
"Sand yellow", 
"Sand violet metallic", 
"Pastel violet", 
"Grey", 
"Tr. Bright bluish violet", 
"Light lilac", 
"Light Royal blue", 
"Really red", 
"Bright red", 
"Dark Curry", 
"Medium green", 
"Light green (Mint)", 
"Light bluish green", 
"Lig. yellowish green", 
"Dark nougat", 
"Light grey metallic", 
"Light grey", 
"Yellow flip/flop", 
"Medium stone grey", 
"Light blue", 
"Med. yellowish green", 
"Neon green", 
"Pastel green", 
"Bright purple", 
"Flame reddish orange", 
"Med. reddish violet", 
"Nougat", 
"Neon orange", 
"Olive", 
"Tr. Brown", 
"Tr. Lg blue", 
"Tr. Flu. Yellow", 
"Tr. Red", 
"Br. reddish orange", 
"Light orange brown", 
"Medium red", 
"Light pink", 
"Flame yellowish orange", 
"Curry", 
"Gold", 
"Light bluish violet", 
"Brick yellow", 
"Mid gray", 
"Tr. Flu. Green", 
"Tr. Yellow", 
"Tr. Flu. Red", 
"Br. yellowish orange", 
"Tr. Flu. Blue", 
"Hot pink", 
"Pink", 
"Tr. Flu. Reddish orange", 
"Med. yellowish orange", 
"Tr. Medi. reddish violet", 
"Bright orange", 
"Medium orange", 
"Light orange", 
"Light reddish violet", 
"Bright yellow", 
"Fire Yellow", 
"Light stone grey", 
"Transparent", 
"Warm yellowish orange", 
"Light red", 
"Lig. Yellowich orange", 
"Light brick yellow", 
"Cool yellow",
"Light yellow", 
"White", 
"Institutional white", 
"Phosph. White", 
"Pastel yellow", 
"Pastel orange",
"Pastel brown",
}

Ad

Answer this question