Help.
script.Parent.MouseClick:connect(function() if script.Parent.Parent.Parent.DOOR.Transparency == 0 then for i = 0, 1, 0.1 do script.Parent.Parent.Parent.DOOR.Transparency = i wait(.01) end script.Parent.Parent.Parent.DOOR.CanCollide = false elseif script.Parent.Parent.Parent.DOOR.Transparency == 1 then for i = 1, 0, -0.1 do script.Parent.Parent.Parent.DOOR.Transparency = i wait(.01) end script.Parent.Parent.Parent.DOOR.CanCollide = true else script.Parent.Parent.BrickColor = BrickColor.new("Really red") wait(.1) script.Parent.Parent.BrickColor = BrickColor.new("Toothpaste") end end)
I'm making a multistage rocket but I need a way for the astronauts to get in. I decided to make a button door rather than setting a brick's cancollide property to false. I want it to fade in and out. I've tried with for loops and it isn't working.
It opens and closes once but doesn't ever again.
script.Parent.MouseClick:connect(function() if script.Parent.Parent.Parent.DOOR.Transparency == 0 then for i = 0, 1, 0.1 do script.Parent.Parent.Parent.DOOR.Transparency = i wait(.01) end script.Parent.Parent.Parent.DOOR.CanCollide = false elseif script.Parent.Parent.Parent.DOOR.Transparency == 1 then for i = 0, 1, -0.1 do script.Parent.Parent.Parent.DOOR.Transparency = i wait(.01) end script.Parent.Parent.Parent.DOOR.CanCollide = true end end)
I changed your line 9 and I deleted the else statement. If you put a negative number in a for loop it will automatically count down from the second value. See if this works.