How to set debounce to false when user touches a new part

Hello, how can i set debounce to false when the player touches a new part / “tile”?
Right now my script has a 1 second debounce but i want the debounce to be set to false when the user touches a new part so i can create a fluid “tile minigame”
Thank you in advance!

My current script:

local CollectionService = game:GetService("CollectionService")
local taggedTiles = CollectionService:GetTagged("Tile")
local tileParent = game.Workspace.Floor:GetChildren()
local isScriptRunning = false

for _, tilePart in pairs(taggedTiles) do
	tilePart.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") and isScriptRunning == false and tilePart.Name == "Union" then
			isScriptRunning = true

			local player = game.Players:FindFirstChild(hit.Parent.Name)
			player.leaderstats.Points.Value =  player.leaderstats.Points.Value + 1


			for i = 0, 1, 0.05 do
				tilePart.Transparency = i
				wait()
			end

			tilePart.CanCollide = false
			tilePart.Name = "DestroyedTile"
			tilePart.Parent = game.Workspace.DestroyedTiles
			isScriptRunning = false
		end
	end)
end ```

Do you mean you want each tile to have its own debounce, instead of sharing one?

Or do you want touching the same part twice to do nothing, and only trigger when a new part is touched?

Second option, touching the same part multiple times should do nothing, the script should only run the first time you touch that part.
Right now my script won’t run again before its finished even if a new part is touched. I want the script to not run on the same part twice but to run when a new part is touched.

If you basically want a debounce for each part then you can put your debounce variable inside the loop.

local CollectionService = game:GetService("CollectionService")
local taggedTiles = CollectionService:GetTagged("Tile")
local tileParent = game.Workspace.Floor:GetChildren()

for _, tilePart in pairs(taggedTiles) do
    local isScriptRunning = false

	tilePart.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") and isScriptRunning == false and tilePart.Name == "Union" then
			isScriptRunning = true

			local player = game.Players:FindFirstChild(hit.Parent.Name)
			player.leaderstats.Points.Value += 1

			for i = 0, 1, 0.05 do
				tilePart.Transparency = i
				wait()
			end

			tilePart.CanCollide = false
			tilePart.Name = "DestroyedTile"
			tilePart.Parent = game.Workspace.DestroyedTiles
			isScriptRunning = false
		end
	end)
end

Thank you, can’t believe it was so simple. Thanks.