Perfect One Way Door

Greetings, I’ve been making an One Way Door, I did get a script which was helpful and working but the problem with the door is that players could stay IN the door making them go inside or outside, which is pretty annoying if you ask me, even sometimes players reach the censor switching ON the door. Any helpful script? Any helpful videos on YouTube? Someone?

Thanks!

Script:

censor = game.Workspace.Censor
door= game.Workspace.Door 
debounce = true

function touchingCensor(hit)
 if debounce == true then
  debounce = false
  print("touched")
  door.CanCollide = false
  door.Transparency = 1
  wait(2)
  door.CanCollide = true
  door.Transparency = 0
  debounce = true 
 end
end
censorPart.Touched:Connect(touchingCensor)

The player gets stuck between because of the physics. Which is a good thing. You could instead teleport them to the other side to mitigate this, but at the same time why are you staying in the middle. Of course that will happen.

You could just use invisible parts, one in front of the door, and script that to make the door open. This would make it only one way, achieving your goal.

  1. Make an invisible part in front
  2. Use region3 instead of a part
  3. Compare camera lookVector with the doors lookVector.
  4. NetworkOwnership, check whenever client gets physics ownership over it.
  5. Compare Magnitude of lookVector of the door to its backVector. If look < back and dist > look then
  1. Easy but bad practice and unreliable
  2. Most accurate and best practice
  3. Overcomplicated but works and its use case is very specific
  4. Advanced and vulnerable but a huge learning experience
  5. Easy and reliable but inefficient
2 Likes