local Door = script.Parent -- Door is part's parent now
function onTouch()--Sets start of function
Door.CanCollide = false -- Allows you to go through the door
Door.Transparency = 0.5 -- Makes the door transparent(duh)
Door.BrickColor:Random() -- Makes the door change color, problem is here.
wait(2) -- waits EXACTLY 2 seconds :/
Door.CanCollide = true -- Now the door is solid again
Door.Transparency = 0 -- Door's transparency is gone
Door.BrickColor:Random()-- another random color is added -- also problem.
end
Door.Touched:connect(onTouch)--idk
✓ ANSWER ACCEPTED
What is wrong with the color change in this door?
2 answers
✓ Accepted answer
:Random() doesn't work here.
This should work.
local Door = script.Parent -- Door is part's parent now
function onTouch()--Sets start of function
Door.CanCollide = false -- Allows you to go through the door
Door.Transparency = 0.5 -- Makes the door transparent(duh)
Door.BrickColor = BrickColor.new(math.random(), math.random(), math.random()) -- BrickColor is done in (R, G , B)
wait(2) -- waits EXACTLY 2 seconds :/
Door.CanCollide = true -- Now the door is solid again
Door.Transparency = 0 -- Door's transparency is gone
Door.BrickColor = BrickColor.new(math.random(), math.random(), math.random()) -- Same as above.
end
Door.Touched:connect(onTouch)--idk
The BrickColor property is designed to be an (R, G, B) property, meaning you must supply 3 numbers to create a color, or specify the actual name of a color within the initial color palette. For random colors/numbers, use math.random() for all your RNG* needs.
*Random Number Generating/Generator/Generated etc.
1 comment
1
BrickColor.Random() would work though.
BrickColor is different than random, use BrickColor.Random() instead Good work on the commenting
1 comment
0
I like things simple.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Door.BrickColor=BrickColor.Random()