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

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

Asked by 3 years ago

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

Log in to vote
0
Answered by
Zeuxulaz 148
3 years ago

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

part.BrickColor = BrickColor.Yellow()
0
I didn’t even know you had to do that lol iivSnooxy 248 — 3y
0
Thank you Retallack445 75 — 3y
0
No problemo Zeuxulaz 148 — 3y
Ad
Log in to vote
0
Answered by
sngnn 274 Moderation Voter
3 years ago
Edited 3 years ago

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()
0
Thank you Retallack445 75 — 3y
Log in to vote
0
Answered by
stef0206 125
3 years ago

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.

Answer this question