generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: ok, so DataStore cant save instances, but..

Previous Thread :: Next Thread 
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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 is online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
31 May 2014 06:13 PM
Yes, you can save a table to DataStore.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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 is online. 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
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
31 May 2014 06:20 PM
but, IN THEORY, this is correct, right?
Report Abuse
wazap is not online. 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
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
31 May 2014 06:23 PM
but idk how to decode it.. q.q
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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 is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
31 May 2014 06:32 PM
yes
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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 is not online. wazap
Joined: 29 Jun 2007
Total Posts: 23234
31 May 2014 06:33 PM
That should work.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
31 May 2014 06:36 PM
hurrah, this is gonna be good if all works out well
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
31 May 2014 06:46 PM
I would rather use DataPersistence, even though DataStore is better.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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 is online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image