Weird table behaviour

Hello, I’m having a problem that I literally have no idea where it comes from or how to solve it. What’s happening is that i have a regular table with 7 keys, and then I iterate through it. However, it doesn’t go through any index higher than 6 for some reason.

local Binds = {
	[1] ={
		["Type"] = Enum.UserInputType.Keyboard;
		["Hold"] = false;
		["Key"] = Enum.KeyCode.One;
		["Name"] = "1",
		["Trigger"] = function()
			Modules.Control:Activated(1)
		end
	},
	[2] ={
		["Type"] = Enum.UserInputType.Keyboard;
		["Hold"] = false;
		["Key"] = Enum.KeyCode.Two;
		["Name"] = "2",
		["Trigger"] = function()
			Modules.Control:Activated(2)
		end
	},
	[3] ={
		["Type"] = Enum.UserInputType.Keyboard;
		["Hold"] = false;
		["Key"] = Enum.KeyCode.Three;
		["Name"] = "3",
		["Trigger"] = function()
			Modules.Control:Activated(3)
		end
	},
	[4] ={
		["Type"] = Enum.UserInputType.Keyboard;
		["Hold"] = false;
		["Key"] = Enum.KeyCode.Four;
		["Name"] = "4",
		["Trigger"] = function()
			Modules.Control:Activated(4)
		end
	},
	[5] ={
		["Type"] = Enum.UserInputType.Keyboard;
		["Hold"] = false;
		["Key"] = Enum.KeyCode.Five;
		["Name"] = "5",
		["Trigger"] = function()
			Modules.Control:Activated(5)
		end
	},
	[6] ={
		["Type"] = Enum.UserInputType.Keyboard,
		["Key"] = Enum.KeyCode.LeftShift,
		["Name"] = "Sprint",
		["Hold"] = true,
		["Trigger"] = function(Down)
			Modules.Control:Activated("Sprint",Down)
		end,
	},
	[7]={
		["Type"] = Enum.UserInputType.Keyboard,
		["Key"] = Enum.KeyCode.R,
		["Name"] = "Equip",
		["Hold"] = false,
		["Trigger"] = function()
			Modules.EquipItem:Equip()
		end,
	}
}

for Index,Bind in pairs(Binds) do
	print(Index) -- 1,2,3,4,5,6
    end

Pasting your code here I got:

  1
  2
  3
  4
  5
  6
  7

I didn’t post some part of the code because I thought it wouldn’t change anything, but turns out it does. If you copy and paste my code you will get the 6,7; however if you include the rest of the code (read bellow) it stops at 6.

for Index,Bind in pairs(Binds) do
print(Index)
if Bind.Type == Enum.UserInputType.Keyboard and Index > 5 then
			ContextActionService:BindAction(Bind.Name,function(_,State)
				if State == Enum.UserInputState.End and not Bind.Hold then
					return
				end
				Bind.Trigger(State == Enum.UserInputState.Begin and true or false)
			end,true,Bind.Key)
			local btn = ContextActionService:GetButton(Bind.Name)
			btn:SetText(Bind.Name)
		elseif Bind.Type == Enum.UserInputType.Keyboard and Index <= 5 then
			self.Connections[Index] = Player.PlayerGui.Main.MainInGame.hotbar.Frame[Index].Activated:Connect(function()
				Bind.Trigger(true)
			end)
			ContextActionService:BindAction(Bind.Name,function(_,State)
				if State == Enum.UserInputState.End and not Bind.Hold then
					return
				end

				Bind.Trigger(true)
			end,false,Bind.Key)
		end
end

Yeah, I’m trying to help you, but your code is missing a lot of variables and I can’t simulate it.
Use Studio debugging, this will make it easier.

What variables are missing? And what do you mean with studio debug?

Turns out if I take this part off, it does go through all the table, I don’t really understand why tho, plus that part was kinda crucial :confused:

local btn = ContextActionService:GetButton(Bind.Name)
btn:SetText(Bind.Name)