How do you make a one way door so it can only be opened from one side? I made a one way door that pushes players n a certain direction, but it is a bit faulty.
door = script.Parent function open() door.Transparency = 0.5 door.Anchored = true door.CanCollide = false end function close() door.Transparency = 0 door.Anchored = false door.CanCollide = true end reloading = false function touched(hit) if hit~= nil then if hit.Parent~= nil then if game.Players:FindFirstChild(hit.Parent.Name)~= nil then if hit.Parent:FindFirstChild("Torso")~= nil then look = hit.Parent:FindFirstChild("Torso").Velocity.unit*10 look2 = hit.Parent:FindFirstChild("Torso").CFrame.lookVector*10 pt = (door.CFrame*CFrame.new(0, 0, -200000)).p -- waaay ahead in front dooroff = door.Position-look dooroff2 = door.Position-look2 if ((pt-dooroff).magnitude<(pt-door.Position).magnitude and (pt - dooroff2).magnitude<(pt-door.Position).magnitude) then if reloading == false then open() reloading = true wait(1) close() reloading = false end else close() -- cant get past even if door is open! end end end end end end door.Touched:connect(touched)
If the door is touched from one part it becomes can collide, if it's from another nothing happens.