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

Possible to save Instances in DataStore?

So I just want to make anyone to know that I'm asking from my brothers account but that's besides the point..

Okay. So I just came back from 2 years to ROBLOX, and I noticed that people uses DataStore instead of Data Presistence.

So my question is, is it possible to save Instances in Datastore?

For example I made an RPG game, I wanted to save the items I got for example a sword.

How would that work?

1 answer

✓ Accepted answer

You can't directly save instances in a data store. However, you could store a literal interpretation of the instance. The two easiest ways to do this is to store an integer or a string.

###Integer Method ####Example:

local objects = {part, sword, tool, block} -- assuming those are defined

for index, object in next, objects do
	print(index, " = ", object)
end
--[[
Output:
	1 = part
	2 = sword
	3 = tool
	4 = block
]]

Thus you could save the index, and then later retrieve the index and thus the object by objects[index].

###String Method This method requires you to have a folder or model of all the objects you want to save. All you do is simply save the name of the object and then you can later retrieve the object with a simple FindFirstChild call. However, each object will need to have a unique name unlike the integer method.

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