How about a simple string.format with %c?
--- Returns the string prefixed with its length, as used in the BungeeCord protocol local function writeProtocolString(a_Str) local len = a_Str:len() return string.format("%c%c%s", math.floor(len / 256), math.floor(len % 256), a_Str) end -- usage: client:SendPluginMessage("BungeeCord", writeProtocolString("Connect") .. writeProtocolString("SomeServer"))