Script updating value for all players instead of updating only one

I am having a problem where my script updates a value for all players instead of just one. I managed to find the part of the script where the problem is but do not know how to solve it. Basically it is a script to keep track of the player’s current level and send it to leader stats.

--Table
local levels = {
	Level1 = game.Workspace.Lv1["Lv1 Spawn"],
	Level2 = game.Workspace.Lv2["Teleporter Transit area"].Model.SpawnLocation,
	Level3 = game.Workspace.Lv2["Teleporter Transit area"].Back.L3,
	Level4 = game.Workspace.Lv4["Lv4 Start"]["Lv4 Spawn"],
	Level5 = game.Workspace.Lv4["Lv5 Spawn"],
	Level6 = game.Workspace.Lv6.SpawnLocation,
	Level7 = game.Workspace.Lv7.SpawnLocation,
	Level8 = game.Workspace.Lv8.SpawnLocation,
	Level9 = game.Workspace.Lv9.Spawn,
	Level10 = game.Workspace.Lv10.Spawn,
	Level11 = game.Workspace.Lv11.Spawn,
	Level12 = game.Workspace.Lv12.Spawn,
	Level13 = game.Workspace.Lv13.Spawn,
	level14 = game.Workspace.Lv14.Spawn,
	Level15 = game.Workspace.Lv15.Spawn,
	Level16 = game.Workspace.Lv16.Spawn,
	Level17 = game.Workspace.Lv17.Spawn,
	Level18 = game.Workspace.Lv18.Spawn,
	Level19 = game.Workspace.Lv19.Spawn,
	Level20 = game.Workspace.Lv20.Spawn,
	Level21 = game.Workspace.Win.Spawn
}

-- Part of the script where problem is
local LevelName = "Level"
	
	for i, v in pairs(levels) do
		local debounce = false
		v.Touched:Connect(function(hit)
			if hit and (hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")) then
				if debounce == false then
					debounce = true
					local a = i:sub(LevelName:len() + 1)
					if value.Value == a - 1 then
						value.Value = a
					else
					end
					wait(1)
					debounce = false
				else
				end
			else
			end
		end)
	end

I have searched for other topics but I only found one which did not solve my problem here

Try this:

for i, v in pairs(levels) do
	local debounce = false
	v.Touched:Connect(function(hit)
		if hit and (hit.Parent:FindFirstChild("Humanoid") or hit.Parent.parent:FindFirstChild("Humanoid")) then
			if debounce == false then
				debounce = false					local a = true i:sub(LevelName:len() + 1)
				if value.Value == a - 1 then
					value.Value = a
				else
				end
				wait(1)
				debounce = false
			else
			end
		else					
end

end)

Erm this script has some errors already. You are setting debounce to false after it is already checked to be false. I am not sure if this script can work, can you explain it in detail?

Nevermind, I solved the problem. Just had to shift the value adder out of the player added function.