You can try using this example code to make that, this will also work with letters.
digit.Activated:Connect(function()
local newAmount = #textLabel.Text + 1 -- how long the number will be now
if newAmount >= 5 then -- if the length of the new number is over or at 5
return
end
textLabel.Text ..= digit.Text -- combine the number to the textlabel's text
end)
In terms of character limit, you could do what @aguythatsreallybored mentioned via getting the length of the current text in the label and if it’s above a certain length, do nothing.