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

What is wrong with the color change in this door?

Asked by 10 years ago
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

0
Door.BrickColor=BrickColor.Random() M39a9am3R 3210 — 10y

2 answers

Log in to vote
1
Answered by
OniiCh_n 410 Moderation Voter
10 years ago

: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
BrickColor.Random() would work though. TheGuyWithAShortName 673 — 10y
Ad
Log in to vote
3
Answered by
devDave 50
10 years ago

BrickColor is different than random, use BrickColor.Random() instead Good work on the commenting

0
I like things simple. BritishGotSwag 30 — 10y

Answer this question