Proximity Prompt Problem (Resolved)

Hey there, I’m new to posting here. But maybe I’m overlooking something, what is causing this door to not open whenever you ‘attempt’ to open it whenever it’s locked?

Example of issue

Code
-- Functions --

local function DoorLock()
	if Locked == true then
		ProxPrompt2.ActionText = 'Lock Door'
		print('Locked Door')
		Locked = false
		LockSound:Play()
		print(Locked)
	else
		ProxPrompt2.ActionText = 'Unlock Door'
		print('Unlocked Door')
		Locked = true
		LockSound:Play()
		print(Locked)
	end
end

local function DoorFunction()
	if debounce == true then
		debounce = false
		if Locked == false then
			if IsOpened == true then
				ProxPrompt.ActionText = 'Open Door'
				IsOpened = false
				CloseSound:Play()
				tweenService:Create(Frame,TweenInfo.new(0.65),{CFrame = DoorClose.CFrame}):Play()
				tweenService:Create(Frame2,TweenInfo.new(0.65),{CFrame = HandleClose.CFrame}):Play()
			else
				IsOpened = true
				ProxPrompt.ActionText = 'Close Door'
				OpenSound:Play()
				tweenService:Create(Frame,TweenInfo.new(0.65),{CFrame = DoorOpen.CFrame}):Play()
				tweenService:Create(Frame2,TweenInfo.new(0.65),{CFrame = HandleOpen.CFrame}):Play()
			end
			wait(0.65)
			debounce = true
		end
		 else
		LockedOpen:Play()
		print('Door Is Locked')
	end
end

ProxPrompt2.Triggered:Connect(DoorLock)
ProxPrompt.Triggered:Connect(DoorFunction)

I don’t know if this is on my end, or this happens to be a bug. Again, extremely unsure if I’m looking something over or not. Please do let me know a fix, and why it’s fixed in the comments if possible.

Thank you for your time, I hope you had a wonderful Christmas! :blue_heart:

It seems that there is a variable called Locked that is checked; after setting the debounce to false, the Locked variable is checked for if it is false. If it is, then it’ll open or close the door. If it isn’t, then it’ll play a sound and print “Door Is Locked”.

P.S.: I don’t think there’s anything wrong here, seems like it’s working as intended.

Upon watching the video, you’d see that after the ‘attempt’ is made, then you unlock the door and try to open, it will not open. Regardless of being unlocked.

That’s the issue I’m having.

Try printing the value of Locked after

local function DoorFunction()
	if debounce == true then
		debounce = false

Hey there, just informing you. After re-writing the code, my else statement for opening the door was in the wrong place, and it’s now working!

Just tired, that’s all! Thanks for the help!