IntValue Decreases as number it shouldn't be!

What do you want to achieve? Keep it simple and clear!
I want the value ALWAYS decrease 1 Instead of 2,3,4 etc.
What is the issue? Include screenshots / videos if possible!
When I use the function 1st time, everything works fine! Like the value decreases 1, and etc. But when I use it more than 1 times, the value starts to decrease more than 1, like 2nd use, the value decreases 2, 3rd use, the value decreases 3 etc.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Well, I Couldn’t find any topic like this neither in devforum neither in Developer Hub.

The script is;

	local FoodDebounce = false
	local function OpenItemStuff()
		local Collected = 0
		local Repeat = 0
		local FoodFolder = Player:WaitForChild("Foods")
		Dialogue.MainText.SurfaceGui.Text.Text = ""
		local FoodInLighting = nil
		local FoodList = {}
		for i, v in pairs(FoodFolder:GetChildren()) do
			if v.Value == 1 or v.Value > 1 then
				Collected = Collected + v.Value
				FoodInLighting = game.Lighting.Food:FindFirstChild(v.Name)
				Repeat = v.Value
				repeat
					local success, fail = pcall(function()
						table.insert(FoodList, FoodInLighting.Name)
					end)
					Repeat = Repeat -1
				until Repeat == 0
				print(#FoodList)
				print(Collected)
				Dialogue.MainText.SurfaceGui.Text.Text = ""
			end
		end
		if not FoodDebounce then
			FoodDebounce = true
			if FoodList[1] then
				Dialogue.Food1.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[1]).FoodName.Value
				Dialogue.Food1.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food1.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					CloseItemStuff()

					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[1]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[1]).Tool.Food.WhenHealed:Fire(Player)
					FoodFolder:FindFirstChild(FoodList[1]).Value = FoodFolder:FindFirstChild(FoodList[1]).Value - 1
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()
					return
				end)
			end
			if FoodList[2] then
				Dialogue.Food2.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[2]).FoodName.Value
				Dialogue.Food2.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food2.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[2]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[2]).Tool.Food.WhenHealed:Fire(Player)
					FoodFolder:FindFirstChild(FoodList[2]).Value = FoodFolder:FindFirstChild(FoodList[2]).Value - 1
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()

					return
				end)
			end
			if FoodList[3] then
				Dialogue.Food3.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[3]).FoodName.Value
				Dialogue.Food3.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food3.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[3]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[3]).Tool.Food.WhenHealed:Fire(Player)
					FoodFolder:FindFirstChild(FoodList[3]).Value = FoodFolder:FindFirstChild(FoodList[3]).Value - 1
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()

					return
				end)
			end
			if FoodList[4] then
				Dialogue.Food4.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[4]).FoodName.Value
				Dialogue.Food4.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food4.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					FoodFolder:FindFirstChild(FoodList[4]).Value = FoodFolder:FindFirstChild(FoodList[4]).Value - 1
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[4]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[4]).Tool.Food.WhenHealed:Fire(Player)
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()

					return
				end)
			end
			if FoodList[5] then
				Dialogue.Food5.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[5]).FoodName.Value
				Dialogue.Food5.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food5.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					FoodFolder:FindFirstChild(FoodList[5]).Value = FoodFolder:FindFirstChild(FoodList[5]).Value - 1
					HealSound:Play()
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[5]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[5]).Tool.Food.WhenHealed:Fire(Player)
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()

					return
				end)
			end
			if FoodList[6] then
				Dialogue.Food6.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[6]).FoodName.Value
				Dialogue.Food6.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food6.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					FoodFolder:FindFirstChild(FoodList[6]).Value = FoodFolder:FindFirstChild(FoodList[6]).Value - 1
					HealSound:Play()
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[6]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[6]).Tool.Food.WhenHealed:Fire(Player)
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()

					return
				end)
			end
			if FoodList[7] then
				Dialogue.Food7.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[7]).FoodName.Value
				Dialogue.Food7.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food7.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					CloseItemStuff()
					FoodFolder:FindFirstChild(FoodList[7]).Value = FoodFolder:FindFirstChild(FoodList[7]).Value - 1
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[7]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[7]).Tool.Food.WhenHealed:Fire(Player)
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()
				
					return
				end)
			end
			if FoodList[8] then
				Dialogue.Food8.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[8]).FoodName.Value
				Dialogue.Food8.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food8.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[8]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[8]).Tool.Food.WhenHealed:Fire(Player)
					FoodFolder:FindFirstChild(FoodList[8]).Value = FoodFolder:FindFirstChild(FoodList[8]).Value - 1
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()
					
					return
				end)
			end
			wait(1)
			FoodDebounce = false
		end

Any help is appreciated! By the way if you need some more information about the script, go and ask! I’ll help as much as I can.

Are you talking about Repeat?

Found here:

Sorry for the late answer.
No. Repeat is working completely fine. Im Talking about the v.Value, as you can see at the lower lines. It must decrease 1. It works fine at 1st try, but at other tries, the number goes down 2,3,4,5 etc.

probably because there is an old function that still works causing it to double and double each time

Hmm. Your comment makes very much sense. Because I keep using function when player presses the button, but never ending it. I’ll try finishing the function after it’s job is finished.

Hello, uhh… I still believe the thing you said but it didnt work again, what i changed is

	local function OpenItemStuff()
		local FoodDebounce = false
		if not FoodDebounce then
		FoodDebounce = true
		local Collected = 0
		local Repeat = 0
		local FoodFolder = Player:WaitForChild("Foods")
		Dialogue.MainText.SurfaceGui.Text.Text = ""
		local FoodInLighting = nil
		local FoodList = {}
		for i, v in pairs(FoodFolder:GetChildren()) do
			if v.Value == 1 or v.Value > 1 then
				Collected = Collected + v.Value
				FoodInLighting = game.Lighting.Food:FindFirstChild(v.Name)
				Repeat = v.Value
				repeat
					local success, fail = pcall(function()
						table.insert(FoodList, FoodInLighting.Name)
					end)
					Repeat = Repeat -1
				until Repeat == 0
				print(#FoodList)
				print(Collected)
				Dialogue.MainText.SurfaceGui.Text.Text = ""
			end
		end

			if FoodList[1] then
				Dialogue.Food1.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[1]).FoodName.Value
				Dialogue.Food1.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food1.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					CloseItemStuff()

					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[1]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[1]).Tool.Food.WhenHealed:Fire(Player)
					FoodFolder:FindFirstChild(FoodList[1]).Value = FoodFolder:FindFirstChild(FoodList[1]).Value - 1
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()
					return
				end)
			end
			if FoodList[2] then
				Dialogue.Food2.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[2]).FoodName.Value
				Dialogue.Food2.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food2.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[2]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[2]).Tool.Food.WhenHealed:Fire(Player)
					FoodFolder:FindFirstChild(FoodList[2]).Value = FoodFolder:FindFirstChild(FoodList[2]).Value - 1
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()

					return
				end)
			end
			if FoodList[3] then
				Dialogue.Food3.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[3]).FoodName.Value
				Dialogue.Food3.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food3.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[3]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[3]).Tool.Food.WhenHealed:Fire(Player)
					FoodFolder:FindFirstChild(FoodList[3]).Value = FoodFolder:FindFirstChild(FoodList[3]).Value - 1
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()

					return
				end)
			end
			if FoodList[4] then
				Dialogue.Food4.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[4]).FoodName.Value
				Dialogue.Food4.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food4.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					FoodFolder:FindFirstChild(FoodList[4]).Value = FoodFolder:FindFirstChild(FoodList[4]).Value - 1
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[4]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[4]).Tool.Food.WhenHealed:Fire(Player)
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()

					return
				end)
			end
			if FoodList[5] then
				Dialogue.Food5.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[5]).FoodName.Value
				Dialogue.Food5.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food5.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					FoodFolder:FindFirstChild(FoodList[5]).Value = FoodFolder:FindFirstChild(FoodList[5]).Value - 1
					HealSound:Play()
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[5]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[5]).Tool.Food.WhenHealed:Fire(Player)
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()

					return
				end)
			end
			if FoodList[6] then
				Dialogue.Food6.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[6]).FoodName.Value
				Dialogue.Food6.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food6.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					FoodFolder:FindFirstChild(FoodList[6]).Value = FoodFolder:FindFirstChild(FoodList[6]).Value - 1
					HealSound:Play()
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[6]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[6]).Tool.Food.WhenHealed:Fire(Player)
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()

					return
				end)
			end
			if FoodList[7] then
				Dialogue.Food7.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[7]).FoodName.Value
				Dialogue.Food7.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food7.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					CloseItemStuff()
					FoodFolder:FindFirstChild(FoodList[7]).Value = FoodFolder:FindFirstChild(FoodList[7]).Value - 1
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[7]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[7]).Tool.Food.WhenHealed:Fire(Player)
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()
				
					return
				end)
			end
			if FoodList[8] then
				Dialogue.Food8.SurfaceGui.Text.Text = game.Lighting.Food:FindFirstChild(FoodList[8]).FoodName.Value
				Dialogue.Food8.ClickDetector2.MaxActivationDistance = 32
				Dialogue.Food8.ClickDetector2.MouseClick:Connect(function()
					local HealSound = game.Lighting.Assets.Battle.Heal:Clone()
					HealSound.Parent = FightFolder
					HealSound:Play()
					CloseItemStuff()
					MonsterCharacter.Main.Events.UseItem:Fire(tostring(FoodList[8]), Dialogue.MainText.SurfaceGui.Text)
					game.Lighting.Food:FindFirstChild(FoodList[8]).Tool.Food.WhenHealed:Fire(Player)
					FoodFolder:FindFirstChild(FoodList[8]).Value = FoodFolder:FindFirstChild(FoodList[8]).Value - 1
					local success, fail = pcall(function()
						table.remove(FoodList, table.find(FoodList, FoodInLighting.Name))
					end)
					wait(MonsterCharacter.Main.Values.TimeWaitForPass.Value + 1)
					TakeAwayTurn()
					
					return
				end)
			end
			wait(1)
		end

And… It doesnt seems to work.

Hello. So, Im making this reply solution, and here’s how I solved my problem.
So, I removed the table.remove’s, and instead i just resetted the whole FoodList table. If any more information needed just reply this comment.