Any way to save scripts using DataStore or an alternative? For players

As title says, I can’t save my ModuleScript for players as I am getting this error:

18:09:30.883 DataStoreService: CantStoreValue: Cannot store Instance in data store. Data stores can only accept valid UTF-8 characters. API: SetAsync, Data Store: save_Memory - Studio

you cannot save a script, but i think you can save the scripts content:

to achieve this you could use script.Source

now this may not work because it is intended for plugins but always worth a shot.

Do I need a plugin for that to work?

I am now getting this error right now:

  18:17:08.084  Failed to save script content for: henrydanger5472: The current thread cannot read 'Source' (lacking capability Plugin)  -  Server - SaveScript:34

i stated that this is made for plugins, and may only for work for plugins

i do not know any other ways to save a scripts source.

if you wanna save like a script try using loadstrings (works only on serverside) basically
save the string in the loadstring and it’ll work just fine to load it just do loadstring(“string here”)()

i dont think you can directly save a script

1 Like

why are you even trying to save a module script in the first place?

what is the need behind this. (because there may be a way better way)

I need to put the entire script in there? And then save/load it?

If so, how do I load it in the script?

Memory, basically the ModuleScript acts as a memory for an AI.

The players can thus train their own AI and thus it needs to be saved.

why don’t you just save a table instead of saving a whole entire module script?

I don’t believe that much data can be stored in datastores.

i think that much data can be, dont forget datastores hold millions if not billions of keys and so much data

(heres an image a found)
image

(the key value was updated to: 4,194,304 per key)

basically you can do

data = datastore:getasync
loadstring(data)() 

thats for loading

for saving idk how to do that ngl cuz i dont use loadstring and “…” brainrot so to save it
you need to get the string inside of the loadstring and save it

So a table with like billions of things can be stored with a data store? While there are also a lot of tables?

actually saving A WHOLE SCRIPT is wayyy more space taking

1 Like

Oh, but I don’t think it’s efficient to store hundreds of millions of lines of data in a loadstring().

it isnt effiecent but i dont think theres like a way to make a script ingame rather than this and the fact when ur saving a script thats like 400 lines and say 50 letters per line thats like 20k bytes but tables are wayyy more effiecent since you can shorten thing in them and try to compress them unlike A WHOLE SCRIPT

maybe you need a database outside of roblox, that sounds like a good solution

Well, then I will try this untill maybe there will come a new thing.

Don’t know how to make one. Do I need hardware myself for that?