Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to add custom data files to Roblox DataModel?

I also asked this question in this StackOverflow post (where I am more likely to actually see an answer, because I am not checking this site or my related e-mail very often):

I don't seem to be able to add textual data (e.g. in CSV, JSON or XML files) to the Roblox DataModel, Workspace, ServerStorage or anywhere really?

Any hints on how to do this efficiently? Ideally, Roblox should just give me the contents of the file as a table. But if there is a way to get a raw string from a file that I have to parse manually, I could cope, too.

3 comments

0

you will have to decode it sorry

0

@EssentialRoll, that's fine with me - But how do I actually add text to my project? Is there any text file format, other than scripts? Can I somehow import raw text data into my project that I can then access with Lua?

0

A StringValue can let you store text in it, and then access it later. Just keep in mind that it has a limited data size.

1 answer

Unfortunately, there is no file format other than scripts for text. However, Lua has a nice way to create multiline literals:

[[Hello World!
This is a multiline string literal
Neat eh?]]

So you could just copy paste the text file directly into a Roblox script. I suggest using a Module script as you could do something like this to conveniently retrieve the string:

###Module Script:

return function() return [[

This is where 
the text would go

]] end

###Requiring Script:

-- Given the module is named ModuleScript and is parented to workspace
local text = require(game.Workspace.ModuleScript)()

This discussion is preserved as it was. New answers, comments, and votes are closed.