|
| 31 May 2014 06:13 PM |
would it be possible to be like..
Frames = {}
num = 0
for I,v in pairs(Frame:GetChildren()) do
if v:IsA("Frame") then num = num+1 pos = v.Position color = v.BackgroundColor size = v.Size Frames[num] = { Pos = pos, Color = color, Size = size } end
end
DataStore = game:GetService("DataStoreService"):GetDataStore(plr.Name.." Drawing") DataStore:SetAsync(plr.Name.." Stats",Frames)
--can I save a table, that's the question.. |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 31 May 2014 06:13 PM |
| Yes, you can save a table to DataStore. |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 06:17 PM |
ok, so I haven't used datastore, like, ever..
so, how would I get all the items in the table after saving? like..
DataStore = game:GetService("DataStoreService"):GetDataStore(plr.Name.." Drawing") Items = DataStore:GetAsync(plr.Name.." Stats") for I,v in pairs(Items) do f = Instance.new("Frame",Frame) f.Size = v.Size f.Position = v.Pos f.BackgroundColor = v.Color end
would this work? |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 31 May 2014 06:19 PM |
| I don't know, since I don't have the full script. Test it out yourself! Remember to use the F9 console. |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 06:20 PM |
| but, IN THEORY, this is correct, right? |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 31 May 2014 06:22 PM |
No its not possible, as Color and Pos and Size are all UserData, which is equivalent to an Instance
You'd need to convert the Color and Pos and Size to Strings or something. |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 06:23 PM |
| but idk how to decode it.. q.q |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 06:24 PM |
@wazap
ohhhhh
so if I said pos was like
Pos = {pos.X.Scale,pos.X.Offset,pos.Y.Scale,pos.Y.Offset}
I could do that? |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
| |
|
|
| 31 May 2014 06:33 PM |
heres what I have for the saving, bear with me as I have never used DataStore before
is this correct now?
plr = script.Parent repeat plr = plr.Parent until plr:IsA("Player") Frames = {} Frame = plr.PlayerGui.DrawGui.BackDrop num = 0 function Save() for I,v in pairs(Frame:GetChildren()) do
if v:IsA("Frame") then num = num+1 pos = v.Position color = v.BackgroundColor size = v.Size Frames[num] = { Pos = {xScale = pos.X.Scale, xOffset = pos.X.Offset, yScale = pos.Y.Scale, yOffset = pos.Y.Offset}, Color = color.Name, Size = { xScale = size.X.Scale, xOffset = size.X.Offset, yScale = size.Y.Scale, yOffset = size.Y.Offset } } end
end
DataStore = game:GetService("DataStoreService"):GetDataStore(plr.Name.." Drawing") DataStore:SetAsync(plr.Name.." Stats",Frames) end
|
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
| |
|
|
| 31 May 2014 06:36 PM |
| hurrah, this is gonna be good if all works out well |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 06:39 PM |
okkkkkkk so, with this newfound knowledge, this is the loading system
function Load(plr) DataStore = game:GetService("DataStoreService"):GetDataStore(plr.Name.." Drawing") Items = DataStore:GetAsync(plr.Name.." Stats") Frame = plr:WaitForChild("PlayerGui"):WaitForChild("DrawGui"):WaitForChild("BackDrop") wait() if Items~=nil and type(Items) == "table" and #Items~=0 then for I,v in pairs(Items) do f = Instance.new("Frame",Frame) size = v.Size x,xx,y,yy = size.xScale,size.xOffset,size.yScale,size.yOffset f.Size = UDim2.new(x,xx,y,yy) pos = v.Pos x,xx,y,yy = pos.xScale,pos.xOffset,pos.yScale,pos.yOffset f.Position = UDim2.new(x,xx,y,yy) f.BackgroundColor = BrickColor.new(v.Color) end end end |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 06:46 PM |
| I would rather use DataPersistence, even though DataStore is better. |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 06:48 PM |
I have to use DataStore, I plan to load the data from the server..
not from the plr..
its going to be like a drawing contest, ingame |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 31 May 2014 06:51 PM |
| What I did for my drawing game, is very inefficient, but I made all the colors into a table and exported/imported from there into DataStore. |
|
|
| Report Abuse |
|
|