I need help with a Unique ID Generator

Hey I need help with a short unique id generator that uses the function utf8.char(). The problem is utf8.char() only has a limited amount of characters and the max index is 1114111. I am trying to fix that problem by adding another character to it’s side and then making it work like so if the first character goes over the limit it adds to the next numbers index but I can’t seem to find out how to do that.

local Index = 1114112
local Max = 1114111

local function NewId()
	local Id
	if Index > Max then
		local CharIndex = math.floor(Index / Max)
		local Remains = Index - CharIndex * Max
	else
		Id = utf8.char(Index)
	end
	
	Index += 1
	return Id
end

print(NewId())