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

Possible to save Instances in DataStore?

Asked by 8 years ago

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

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
8 years ago

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.

Ad

Answer this question