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

How do I make a random part switch to a color, and then switch back to it's original color?

I'm trying to make a part switch from smooth plastic yellow, and then back into it's original color and material. So far, converting back to the original material has worked perfectly fine. However, whenever I try to turn the part back to it's original color, it just sets it to pure black. Any idea to why is this happening and how I can fix this?

local Part = script.Parent
local material = Part.Material
local color = Part.Color

wait(1)

Part.Material = "SmoothPlastic"
Part.Color = Color3.fromRGB(255, 255, 0)

wait(1)

Part.Material = material
Part.Color = Color3.fromRGB(color)


2 answers

✓ Accepted answer

Your color variable is already a Color3 value. Have you tried changing line 11 from:

script.Parent.Color = Color3.fromRGB(color) 

to just be:

script.Parent.Color = color

3 comments

0

This worked thank you!

0

Can you mark my answer as the solution then? Please

0

Gotcha, albeit a bit late

here:

local material = script.Parent.Material
local color = script.Parent.Color

wait(1)

script.Parent.Material = "SmoothPlastic"
script.Parent.Color = Color3.fromRGB(255, 255, 0)

wait(1)

script.Parent.Material = material
script.Parent.Color = color

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