No, literally remove the while loop.
Take the code out of the while loop.
for i = 1,#ButtonChildren do
ButtonChildren[i].MouseButton1Click:Connect(function()
local Name = ButtonChildren[i].Name
local ButtonNum = string.sub(Name,2,2)
print(ButtonNum)
Code = Code..ButtonNum
script.Parent.EnterCode.Text = Code
end)
end