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

Why does my code not work? Lua Roblox i want to change a color of a part but not working

i want to change the color of a part to yellow but This code does not work:

part.BrickColor = BrickColor.Yellow

i also used this code but still not working:

part.BrickColor = Color3.new(255, 255, 0)

please help

3 answers

✓ Accepted answer

You have to put open and closed brackets by Yellow. Like this:

part.BrickColor = BrickColor.Yellow()

3 comments

0

I didn’t even know you had to do that lol

0

Thank you

0

No problemo

You need to define part:

local part = workspace.Part
--or
part = workspace.Part

Also, BrickColor doesn't accept Color3s, so if you used Color3:

part.Color = Color3.new()
-- you could also use Color3.fromRGB() or Color3.fromHSV()

And for BrickColor:

part.BrickColor = BrickColor.new()

1 comment

0

Thank you

When setting the Color of a part you have 2 options.

  1. Use BrickColor or
  2. Use Color3.

When using BrickColor you'd write something like this: Part.BrickColor = BrickColor.new('New Yeller')

Where as when you are using Color3 you again have a couple of options. I personally prefer and recommend using RGB as it is simple to understand. Part.Color3 = Color3.fromRGB(255,255,0) Or you do Part.Color3 = Color3.new(1,1,0)

When you use Color3.new rather than Color3.fromRGB you are working in numbers from 0 to 1 rather than 0 to 255.

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