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 » Scripters
Home Search
 

Re: DataStore question

Previous Thread :: Next Thread 
SimpIyBananas is not online. SimpIyBananas
Joined: 01 Nov 2015
Total Posts: 134
16 Apr 2016 12:36 PM
Can you set a datastore as a table, if so, how would I do this??


Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
16 Apr 2016 12:44 PM
Absolutely.

something:SetAsync(key,{1,2,3,"Hi","Sup",45,65})

You can only save the actual values. And only strings and numbers can save.

What I mean by actual values, stuff like this will be cut off:

{r = 4, 4,5,6, blah = "hey"}


I can't explain this very well I know, but you can't save variables that are in a table.
Report Abuse
SimpIyBananas is not online. SimpIyBananas
Joined: 01 Nov 2015
Total Posts: 134
16 Apr 2016 12:46 PM
So how would I insert a variable into my datastore table?


Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
16 Apr 2016 12:50 PM
Impossible. It tells you on the wiki it will get cut off.

There are workarounds.


Let's say I set the async to this

{"Howdy",45}

And when I get the async, well let's say the first index of the table is the Name, and the second index is the Gold. When we get the async, we can simply do this to access the values:

cowboy_name = GottenAsync[1] --Howdy
cowboy_goldamount = GottenAsync[2] --45


Of course you need valid knowledge of tables to fully understand this concept.
Report Abuse
eRanged is not online. eRanged
Joined: 15 Jun 2013
Total Posts: 9746
16 Apr 2016 12:52 PM
table.insert(yourtable, item.name/item.value)

:SetAsync(key, yourtable)
Report Abuse
SimpIyBananas is not online. SimpIyBananas
Joined: 01 Nov 2015
Total Posts: 134
16 Apr 2016 12:55 PM
So, I'm using universes right, and I want to add variables to a table that already has variables in it. How'd I do that..?


Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
16 Apr 2016 12:57 PM
ds:UpdateAsync(key,function(oldValue)
local new = oldValue[#oldValue + 1] = "NEW_VALUE"
return new
end)

Might have to check myself actually
Report Abuse
SimpIyBananas is not online. SimpIyBananas
Joined: 01 Nov 2015
Total Posts: 134
16 Apr 2016 01:24 PM
Still didn't work. I want the table that's being added too to be the Data store.



Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
16 Apr 2016 04:30 PM
I don't think you're doing the whole process correctly. Post your code. I think the example I posted may be wrong, but I still have doubts.
Report Abuse
spinywind is online. spinywind
Joined: 26 Jan 2012
Total Posts: 3580
16 Apr 2016 04:32 PM
https://www.youtube.com/watch?v=VXcbZ2kurvk

This might help :).



#Code for i,v in pairs (game.Players:GetChildren()) do v:Kick('You're a noob!') end
Report Abuse
SimpIyBananas is not online. SimpIyBananas
Joined: 01 Nov 2015
Total Posts: 134
16 Apr 2016 04:37 PM
This is the place I'm sending it from.

Servers = game:GetService("DataStoreService"):GetDataStore("Servers")
Servers:SetAsync("key", "Server opening")

ServerList = game:GetService("DataStoreService"):GetDataStore("ServersList")

ServerList:UpdateAsync("key",function(ServerList)
local new = table.insert(ServerList,game.JobId)
return new
end)

game.OnClose = function()
ServerList:GetAsync(game.JobId)
Servers:SetAsync("key", "Server closing")
end

THE UNIVERSE HUB

Servers:OnUpdate("key", function(value)
print(value)
end)

ServerList:OnUpdate("key", function(value)
for x = 0,#ServerList do
print(x)
end
end)


Report Abuse
SimpIyBananas is not online. SimpIyBananas
Joined: 01 Nov 2015
Total Posts: 134
16 Apr 2016 05:08 PM
b


Report Abuse
SimpIyBananas is not online. SimpIyBananas
Joined: 01 Nov 2015
Total Posts: 134
16 Apr 2016 05:26 PM
bump


Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
16 Apr 2016 06:42 PM
try this instead i was wrong

ds:UpdateAsync(key,function(oldValue)
oldValue[#oldValue + 1] = "NEW_VALUE"
return oldValue
end)
Report Abuse
SimpIyBananas is not online. SimpIyBananas
Joined: 01 Nov 2015
Total Posts: 134
17 Apr 2016 09:16 AM
Still doesn't work..? Any other ideas?



Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
17 Apr 2016 01:35 PM
Tell me what script you're trying to make and I'll rewrite it for you.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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