I'm having some issues with my password script, I've looked through the code so many times that these two errors are probably in plain sight and I just can't spot them.

The Script

Here are the two problem areas:

154:attempt to call string

The error is found here. The password can be changed once successfully but trying to do it again results in an error.



function settingsmenu1()
cls()
print("Settings Menu")
print(" ")
print(" [ Change Password ] ")
print("   Change Username   ")
print(" ")
print("   Return to Tools Menu  ")
local event, param1 = os.pullEvent() 
if param1 == 200 then 
settingsmenu3()
elseif param1 == 208 then
settingsmenu2()
elseif param1 == 28 then
changepass() -- after calling the changepass function once, trying to call it again yields "154: attempt to call string
end
end

Here is the changepass function:



function changepass()
cls()
write("Enter a new password here: ")
changepass = read()
fs.delete("appsupport/passwordlock/users/"..globaluser.."/password.txt")
passchange = fs.open("appsupport/passwordlock/users/"..globaluser.."/password.txt", "w")
passchange.writeLine(changepass)
passchange.close()
print("Password changed to '"..changepass.."'.")
sleep(2)
settingsmenu1()
end

217: File Exists







function changeuser()
cls()
write("Enter a new username here: ")
changeuser = read()
print(" ")
write("Changing some files.")
fs.makeDir("appsupport/passwordlock/temppass")
sleep(.3)
write(".")
fs.copy("appsupport/passwordlock/users/"..globaluser.."/password.txt", "appsupport/passwordlock/temppass") -- Error occurs here.
sleep(.3)
write(".")
fs.delete("appsupport/passwordlock/users/"..globaluser)
sleep(.3)
write(".")
fs.makeDir("appsupport/passwordlock/user/"..changeuser)
sleep(.3)
write(".")
fs.copy("appsupport/passwordlock/temppass/password.txt", "appsupport/passwordlock/users/"..globaluser.."/password.txt")
if admin == true then
fs.delete("appsupport/passwordlock/admins/"..globaluser)
fs.makeDir("appsupport/passwordlock/admins/"..changeuser)
end
globaluser = changeuser
print("Username changed to '"..changeuser.."'.")
sleep(2)
settingsmenu2()
end