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: DataStore combined with tables

Previous Thread :: Next Thread 
teamkilled is not online. teamkilled
Joined: 14 Apr 2013
Total Posts: 1748
14 Oct 2014 08:06 PM
I'm using datastore currently to store a table of values

I set the datastore as something like "1, 3, 2"
and then I create a table like this

table = {datastore:GetAsync(whatever)}

however, it counts the ENTIRE datastore as one string, so when I print #table, it returns 1 no matter how many commas.

Is there a way I could make the script detect commas to separate the different things from eachother, so that when I return #table, it returns the actual number of things there are in the table?
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
14 Oct 2014 08:07 PM
for _,Value in pairs(Table:GetChildren()) do
Value:SetAsync()
end

for _,Value in pairs(Table:GetChildren()) do
Value:GetAsync()
end
Report Abuse
teamkilled is not online. teamkilled
Joined: 14 Apr 2013
Total Posts: 1748
14 Oct 2014 08:19 PM
That would work if I'm setting a value FROM a table, but I'm GETTING a table from a datastore.
Report Abuse
Locard is not online. Locard
Joined: 13 Apr 2014
Total Posts: 3516
14 Oct 2014 08:30 PM
tab = {1,2,3}

datastore:SetAsync("data",tab)

then to retrieve it...

local new = datastore:GetAsync("data")

print(new[1])
>> 1

print(new[3])
>> 3

print(new[4])
>> nil

The problem with that is that you wouldn't be able to have mixed data in the table. In that case, you would use a dictionary.
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