I have tried to make a basic script that when you touch it, it turns the brick to a random color, makes it half transparent, then in 2 seconds close and change to a random color again.
local Door = script.Parent function onTouch() Door.CanCollide = false Door.Transparency = 0.5 Door.BrickColor = BrickColor:Random() wait(2) Door.CanCollide = true Door.Transparency = 0 Door.BrickColor = BrickColor:Random() end Door.Touched:connect(OnTouch)
You're main problem is here: BrickColor:Random()
However, it should be BrickColor.Random()
Also, you will most likely need a debounce. A debounce is basically a variable that prevents your code from running until it's finished the first time.
You're final code should look like this:
local Door = script.Parent local debounce = false function onTouch() if debounce == false then debounce = true --Stops your code from running until it equals false again. Door.CanCollide = false Door.Transparency = 0.5 Door.BrickColor = BrickColor.Random() wait(2) Door.CanCollide = true Door.Transparency = 0 Door.BrickColor = BrickColor.Random() debounce = false --Let's your code run again end end Door.Touched:connect(onTouch)
Maybe because you are connecting (OnTouch) and not (onTouch)
I'm not sure if this will work, but I think this is the correct way to set a brick's color randomly:
Door.BrickColor = BrickColor.new(math.randon())
also, if you want it to infinitely change color, then you need a while loop:
Door.Touched:connect(function() while wait(2) do Door.BrickColor = BrickColor.new(math.random()) end end)