Is there ANY possible way to save a instance into a data store? If there is please inform me of it.
Instances and DataStores?
3 answers
I don't believe there's a way to save instances just yet if I recall correctly. Unless the instance is modified in the course of the play session, you can save the Name property of the instance, and then load it up later based on said Name.
Otherwise, you might be able to convert instances and their properties into strings or tables of strings, and then saving those to the data stores. You would then have to set the properties from the fetched string to the instance.
It would work look something similar to this.
local package = {
instance1 = {
Parent= model;
...
}
instance2 = {
Parent = model;
...
}
}
x = Instance.new('Part')
x.Name = 'instance1'
for i,v in next, package[x.Name] do
x[i] =v
end
Here is a module by Stravant that should help solve your issue: EncodeInstance Module
2 comments
I think you can actually save instances, datastores:SetAsync("Model", {workspace.Model}), turn it into a table
nein
If anything you can always save the properties of the part.
Yes, just save it as it is:
local ds = game:GetSerivce("DataStoreService"):GetDataStore("Instances")
--You cannot save instances so you should turn it into a string/table
ds:SetAsync("Part", {workspace.Part}) --See if this works
--To access this part you need to do:
ds:GetAsync("Part")[1] --Part
ds:GetAsync("Part")[1].BrickColor = BrickColor.Random()
Hope it helps!(It is late so I need to finish this quickly! Sorry if it's too short.)
The problem with saving is, I was thinking about LoadInstance and SaveInstance, but that is Data Persistence not Data Stores (Silly me). Anyway I think it's fixed.
2 comments
Dude, the reason I'm asking this is because that way of doing it dosn't work. You are unable to directly save an instance to a data store. What I'm asking is if there is any way around a direct save.
This is incorrect. You can not save instances directly into DataStore
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
I'm pretty sure mine works now after I edit it.
There is no way to save an instance. Unless you use data persistence(but it's outdated).