|
| 16 Apr 2016 12:36 PM |
Can you set a datastore as a table, if so, how would I do this??
|
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 16 Apr 2016 12:46 PM |
So how would I insert a variable into my datastore table?
|
|
|
| Report Abuse |
|
|
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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
| |
|
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 |
|
|
|
| 17 Apr 2016 09:16 AM |
Still doesn't work..? Any other ideas?
|
|
|
| Report Abuse |
|
|
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 |
|
|