Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you export .txt files via plugin script? (SOLVED BY ME)

Asked by 3 years ago
Edited 3 years ago

Is of now, it currently possible to export like a .txt file through roblox studio or is this not a thing? You can import a file but I don't think you can download/export. The closest thing you can do is export an obj file but I would have no idea how to decode an obj file.

ANSWER: So, I came up with a pretty good solution. What I did was I created a new script and changed it's code to whatever. Then I used selection service to select this script. Then I did plugin:PromptSaveSelection() This saves it as a .lua file which is basically the same as a .txt file.

function for it:

local Selection = game:GetService("Selection")

function SaveFile(text, filename)
    local Script = Instance.new("Script",game.Workspace)
    Script.Source = text
    Script.Name = "SaveFile"
    Selection:Set({Script})
    plugin:PromptSaveSelection(filename)
    Script:Remove()
end

SaveFile("lololol", "filename")

NOTE: this only works from a plugin or the command line. :))

To load the file you would have to do:

local studioservice = game:GetService("StudioService")
local file = studioservice:PromptImportFile({'lua'})

if file ~= nil then
    file = file:GetBinaryContents()
    print(file)
else
    print("Error loading file!")
end

--You can do whatever you want with the text you got from the file

0
Could you share data cross-servers with this? Necro_las 412 — 3y
0
well game servers no but http servers then.. maybe? MiAiHsIs1226 189 — 2y

Answer this question