Link to a script as a file?

Hi,
I’ve been wanting to read the contents of a script, and in average Lua 5.2 you can just do

file = “path/of/file”

but in ROBLOX doing

file = workspace.file

links it as a object, meaning I cant read and edit the contents of it. How can I read it as a file?

Thanks,
Pevdn

3 Likes

It’s not possible to do File = workspace.file and read it’s contents. Other than that is not possible to create files on Roblox.

Inside of a plugin you can do workspace.script.Source to read and write the contents of a script.

But outside of plugins you could create a modulescript that looks something like this

local content =
[[
Put your text file in here or something
]]
return content

and then require() it to read and edit it.

(you have to wrap the text in an object so that when you require it from another script it shows the same data when changed)

1 Like