Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a door not open when the other door is open?

Alright, so the idea is that there's a set of two doors. One leading into an area and the other leaving. If both doors are closed, the player can successfully open the first door and enter the area. If the player attempts to open the second door they'll be denied access because the first door is open. When they close the first door, they'll be able to open the second door and vice versa.

I have no idea how I would begin scripting this so any help on this would be appreciated.

1 answer

Here is an outline you could do...

door1_open = false
door2_open = false

door1.Touched:connect(function(part)
	if part.Parent:FindFirstChild("Humanoid") and not door2_open then
		door1_open = true
		-- Open door1
		-- To close see below
	end
end)

door2.Touched:connect(function(part)
	if part.Parent:FindFirstChild("Humanoid") and not door1_open then
		door2_open = true
		-- Open door2
		-- To close see below
	end
end)

Not really sure what sort of system you would want for closing the doors, but I could suggest a separate function cooldown looking like this,

function cooldown(door)
	wait(x)
	if door == "Door1" then
		-- Close door1
		door1_open = false
	else
		-- Close door2
		door2_open = false
	end
end

1 comment

0

Should've mentioned this. Both of these doors are opened/closed by keycards. So the door opens/closes when the proper card level is swiped into the keycard reader.

This discussion is preserved as it was. New answers, comments, and votes are closed.