Heres the script function on() isOn = true script.Parent.Transparency = 0. script.Parent.CanCollide = true. end
function off() isOn = false script.Parent.Transparency = .5 script.Parent.CanCollide = false . end
Assuming that you are calling this when you step on a certain brick. (Put this script inside of that brick that you want to call the functions when stepped on.)
01 | isOn = false -- If the brick is transparent or not |
02 | door = game.Workspace.Part -- Change part to the name of the thing you want to be transparent |
03 | function on() -- Opening the door |
04 | isOn = true |
05 | door.Transparency = . 5 |
06 | door.CanCollide = false |
07 | end |
08 | function off() -- Closing the door |
09 | isOn = false |
10 | door.Transparency = 0 |
11 | door.CanCollide = true |
12 | end |
13 | function check() --Decides whether to open the door or close the door |
14 | if isOn = false then --If door is closed then |
15 | on() |
16 | elseif isOn = true then --Otherwise, if the door is open then |
17 | off() |
18 | end |
19 | script.Parent.Touched:connect(check) --When the script's parent is touched, it will start the function check. |