Try this instead:
You're using FindAndDoWithPlayer, but that means he already came online at least once. This means his UUID is already known in the database.
local UUID = cMojangAPI:GetUUIDFromPlayerName(Split[3], true) if (UUID == "") then Player:SendMessageFailure("Invalid Playername") return true end local file = io.open(friendDir .. "/friends.txt", "a") file:write(UUID, "\n") file:close() Player:SendMessageSuccess("Friend added. You can check with /friend [playername]")
You're using FindAndDoWithPlayer, but that means he already came online at least once. This means his UUID is already known in the database.