How can I prevent this?

So I have an animated door, however, it does this:


Script:

EnterT.Touched:Connect(function()
	if not opened then
		opened = true
		openAnim:Play()
		LockSound:Play()
		wait(0.5)
		OpenSound:Play()
		wait(0.5)
		openedAnim:Play()
	end
end)

ExitT.Touched:Connect(function()
	if opened then
		opened = false
		closeAnim:Play()
		OpenSound:Play()
		openedAnim:Stop()
		wait(0.5)
		LockSound:Play()
	end
end)

How can I prevent and fix this?


EnterT.Touched:Connect(function()
	if not opened then
		opened = true
		openAnim:Play()
		LockSound:Play()
		wait(0.5)
		OpenSound:Play()
		openedAnim:Play()
	end
end)

ExitT.Touched:Connect(function()
	if opened then
		opened = false
		closeAnim:Play()
		OpenSound:Play()
		openedAnim:Stop()
		wait(0.5)
		LockSound:Play()
	end
end)

lol that was a easy solution haha