0 votes

I'm not just talking about from a gdscript either. I want to know how to make something like a txt file both from godot UI and from a gdscript

in Engine by (29 points)

1 Answer

+4 votes
Best answer
static func write_file(file_name, string):
    var file = File.new()
    file.open(file_name, File.WRITE)

static func read_file(file_name):
    var file = File.new()
    if !file.file_exists(file_name):

    file.open(file_name, File.READ)

    var array = []
        var line = file.get_line()

    return array
by (249 points)
selected by

I recommend that you create your files in the "user://" path because different platforms may forbid write access to certain paths (including res://).


Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.