Im creating an rpg that uses datastore and since you can't save instances directly how would I create a string that represents an instance?
Assuming you don't have to have instances that are too complex, you could just save an instance with its properties in a table, or even just the name of an instance.
Example:
--Structure: name = {className, parent, transparency, anchored, CanCollide, Size, CFrame) items = { "Name1" = { "Part", workspace, 0.5, true, false, Vector3.new(5, 4, 2), CFrame.new(0,1,0) }, "Name2" = { "Part", workspace, 0.5, true, false, Vector3.new(7, 2, 1), CFrame.new(2,5,1) } }
Then just load the instances by iterating through them:
for name, tbl in pairs(items) do newItem = Instance.New(tbl[1], tbl[2]) newItem.Transparency = tbl[3] newItem.Anchored = tbl[4] newItem.CanCollide = tbl[5] newItem.Size = tbl[6] newItem.CFrame = tbl[7] end
If your instance can have only one set of preset properties, just put it in a folder in ServerStorage. Save the name of the instance and then just clone it from ServerStorage when required.