Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to decode bytestring/bytecode inside a variable?

function ByteString(Obs)
	local New = ""
	local Array = {}
	for i = 1, string.len(Obs) do
	    New = New..string.byte(string.sub(Obs,i,i)).."\\"
	end
	New = string.sub(New,1,string.len(New)-1)
	return(New) -- will return 116\101\115\116
end

local a = (ByteString("test"))

Decode(a) --any way to make this decode it and print it as normal letters?

1 answer

✓ Accepted answer

Combine gsub with char (and tonumber)

function unbyte(s)
  return s:gsub("(%d+)\\?", function(s) string.char(tonumber(s)) end)
end

Should be just about fine.

This discussion is preserved as it was. New answers, comments, and votes are closed.