Tween part debounce

I have looked everywhere and tried a lot of different things to attempt to add a debounce to this script:

local ScannerButton = game.Workspace.ScanButton.ClickDetector
local TweenService = game:GetService("TweenService")
local ScannerPart = game.Workspace.ScannerPart
local enabled = true

ScannerButton.MouseClick:Connect(function()
	local info = TweenInfo.new(
		2,           
		Enum.EasingStyle.Linear,     
		Enum.EasingDirection.InOut,     
		0,                    
		true,                 
		0                      
	)

	local Goals = {             
		Position = Vector3.new(66.8, -0.7, -35.1), 
	}

	local PartTween = TweenService:Create(ScannerPart, info, Goals) 
	PartTween:Play() 

	enabled = true

	ScannerPart.Touched:Connect(function(hit)
		local character = hit.Parent
		local player = game.Players:GetPlayerFromCharacter(character)
		if player ~= nil then
			for i,v in pairs(player.Backpack:GetChildren()) do
				if v:WaitForChild("Contraband").Value == true then
					game.Workspace.ScannerDisplayPart.ScannerScreen.ScannerResults.Text = "ARMED"
				else if v:WaitForChild("Contraband").Value == false then
						game.Workspace.ScannerDisplayPart.ScannerScreen.ScannerResults.Text = "CLEAN"
					end
				end
			end
		end
	end)
end)

Could someone please help; I’m very new to debounce and I have tried so much times to add a debounce.

You can use a debounce like this:

local debounce = false

if debounce == false then 
   -- you can play an open tween here
   debounce = true -- set the debounce to true, so it can play the next thing, if called
else
   if debounce == true then 
   -- play the close tween here
   debounce = false -- Set it back to false, so the close will play, if retriggered.
     end 
end

Here is a (hopefully) easy way to understand it:

Basically, when the debounce is false, we’re almost like assigning that bool value (false) a function. Say it was a number, if false was 1, then the number one would have a specific function.

Now, we tell 1 to do that function, that we assign it to do, but then we want 1 to be able to tell 2 what to do, when one is finished doing its job.

So what you do is, you almost “turn off” one (we set it to true in this matter), so that when the time comes, 2 can come along and see that it’s their turn to run their own function, so 2 does their job, but then 1 needs to do it’s job again, so, 2 “turns off”, by setting the debounce back to false, meaning the function for “false” in the debounce will be triggered.

This could be used like a door, if the door is opened, debounce is true, so that when it’s clicked again, we can play the close, if the debounce is true.

There is only 1 tween that is a part. And it just loops once.

Ok, so you have 1 tween that runs once, what do you want the debounce for?

If I click the button while the tween is playing, it stops and glitches out. It changes positions and just breaks, making it so you can’t click on it any more and run the tween.

Okay, so above, what you could do is

local debounce = false

if debounce == false then 
  -- here you add your script that will play the tween
  debounce = true
else 
   if debounce == true then 
   -- here you will add the stuff to glitch out the part. However, 
   -- if you don't want it to play again, just keep the debounce as true
   end
end