You may not able to use the same password as the login name.
Try this:
function autoLogin()
local cSerial = getPlayerSerial ( source )
local pass_1 = sha256 (cSerial )
local account = getAccount ( tostring(cSerial),pass_1)
if account then
logIn ( source, tostring(cSerial),pass_1)
outputChatBox("Logged in successfully",source,255,255,255)
else
local pass_2 = sha256 (cSerial )
addAccount ( tostring(cSerial), pass_2)
setTimer(function()
if isElement(source) then
logIn ( source, tostring(cSerial),pass_2)
end
end,2000,1)
outputChatBox("Registered and logged in successfully",source,255,255,255)
end
end
addEventHandler ( "onPlayerJoin", root, autoLogin )