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

Instances and DataStores?

Asked by 9 years ago

Is there ANY possible way to save a instance into a data store? If there is please inform me of it.

0
I'm pretty sure mine works now after I edit it. EzraNehemiah_TF2 3552 — 9y
0
There is no way to save an instance. Unless you use data persistence(but it's outdated). EzraNehemiah_TF2 3552 — 9y

3 answers

Log in to vote
0
Answered by
ImageLabel 1541 Moderation Voter
9 years ago

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

0
I think you can actually save instances, datastores:SetAsync("Model", {workspace.Model}), turn it into a table EzraNehemiah_TF2 3552 — 9y
0
nein ImageLabel 1541 — 9y
Ad
Log in to vote
0
Answered by
Kurieita 125
9 years ago

If anything you can always save the properties of the part.

Log in to vote
-1
Answered by 9 years ago

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.

0
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. ClassicTheBlue 65 — 9y
0
This is incorrect. You can not save instances directly into DataStore DigitalVeer 1473 — 9y

Answer this question