How to make a one way door

how do i make a door that you can go one way through but not the other

1 Like

If you have a part on the side you want the player to be able to go through, on the floor, then a local script there that makes the can collide feature of the part false on the players side for a set period like 2seconds. That way they can go through but they cannot go back. Something along those lines maybe. If the door opens with a button, maybe the button is only on that side.

1 Like

add this script to the part:

script.Parent.Touched:Connect(function(Touch)
	if Touch.Parent:FindFirstChild("Humanoid") then
		
		
		task.wait(0.3)
		script.Parent.CanCollide = true
		
		
	end
end)
2 Likes

how would i make it so that you could go through it if you died so bassicly you go through it and you cant go back but then you die and spawn outside of it and can go back through

1 Like

You can use ProximityPrompts for this, they have a property to disable behind wall interactions, so if you put one in a handle and close the door behind the player, they’ll remain locked in.

1 Like

Just make two buttons that will make the door open on the entering side and close on the exiting side

1 Like

If the Player’s Character’s HumanoidRootPart collides with the Part and has a certain Velocity in place (Z-Axis > 0, for example), the Part will become CanCollide false. At 0, the Part will retain its current state, while at the opposite end (Z-Axis < 0, in this case), the Part will become CanCollide true.
Every frame, if the part isn’t CanCollide, quickly set it to collide and find the HumanoidRootPart using GetTouchingParts(), then set its CanCollide based on the velocity.
Not sure how well this would work, considering I’ve never tried it before.

1 Like

You just broke my brain sir thank you

1 Like

I think their solution is over complicating something we can easily do with ProximityPrompts, but I can see why they would post that.

1 Like

its an invisible wall

1 Like

You can probably use something like Vector3:Dot() to do this. Check what side the player is on, if the player isn’t on the front of the door don’t let them through.

Therefore if the Vector3:Dot() == 1 then they are in front, if Vector3:Dot() < 1 then they are beside or behind.

3 Likes

EDIT: Just tried it, it works.

2 Likes