Apparently this only works once. Im not sure why
enabled = true function onTouched(hit) local door1=script.Parent.Parent.Door1 local door2=script.Parent.Parent.Door2 h = hit.Parent:FindFirstChild("Humanoid") if h ~= nil then if not enabled then return end enabled = false door1.CanCollide=false door2.CanCollide=false for i=1,10 do wait() door1.Transparency=door1.Transparency+.1 door2.Transparency=door2.Transparency+.1 end wait(4) for i=1,20 do wait() door1.Transparency=door1.Transparency-.1 door2.Transparency=door2.Transparency-.1 end door1.CanCollide=true door2.CanCollide=true enabled = true end end connection = script.Parent.Touched:connect(onTouched)
val = 0 time = 0 function onTouched(hit) local door1=script.Parent.Parent.Door1 local door2=script.Parent.Parent.Door2 h = hit.Parent:FindFirstChild("Humanoid") if h ~= nil then val = 1 if val == 1 then val = 0 door1.CanCollide=false door2.CanCollide=false for i=1,10 do wait() door1.Transparency=door1.Transparency+.1 door2.Transparency=door2.Transparency+.1 end wait(4) for i=1,10 do wait() door1.Transparency=door1.Transparency-.1 door2.Transparency=door2.Transparency-.1 end door1.CanCollide=true door2.CanCollide=true end end end script.Parent.Touched:connect(onTouched)
You don't need enabled though tell in the comments if it works.
+1 if helped.
Have you tried the loop or wait?
wait(2) --if a function but the function there ex: Fire() fire() end