KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jul 2015 12:11 AM |
Dear "Scripters" subforum.
I wish to save a table using data Store.
I want it to be one table for the game, its not local.
I want it to save when the game ends, and it to load when the game starts.
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2015 12:14 AM |
| Okay, then make the script. |
|
|
| Report Abuse |
|
|
KoreanBBQ
|
  |
| Joined: 06 Mar 2015 |
| Total Posts: 1436 |
|
|
| 10 Jul 2015 12:19 AM |
local dss=game:GetService("DataStoreService") local ds=ds:GetDataStore("YourTableIGuess") local table={a,b,c} plr.PlayerRemoved:connect(function() plr:SetAsync(ds[plr.userId.."table"],table) end)
plr.PlayerAdded:connect(function() table=plr:GetAsync(ds[plr.userID.."table"])
end)
|
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jul 2015 12:20 AM |
| um. i said not a players table, just one HUGE table |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jul 2015 12:20 AM |
| plus, u need to JSom encode + decode |
|
|
| Report Abuse |
|
|
KoreanBBQ
|
  |
| Joined: 06 Mar 2015 |
| Total Posts: 1436 |
|
|
| 10 Jul 2015 12:22 AM |
| what you want to store like a leaderboard or like a physical table lol?? |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
| |
|
|
| 10 Jul 2015 12:23 AM |
local datastoreService = game:GetService("DataStoreService") local dataStore = datastoreService:GetDataStore("SomeDatastore")
local tableKey = "keyForOurTable"
local ourTable = nil
function saveTable() if ourTable == nil then return end dataStore:SetAsync(tableKey, ourTable) end
function getTable() local tab = dataStore:GetAsync(tableKey) return tab end
ourTable = getTable()
game.OnClose = saveTable
while true do wait(60) saveTable() end |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jul 2015 12:24 AM |
game.OnClose = saveTable()*?
do u need those paranethis |
|
|
| Report Abuse |
|
|
KoreanBBQ
|
  |
| Joined: 06 Mar 2015 |
| Total Posts: 1436 |
|
|
| 10 Jul 2015 12:25 AM |
| yeaaaaah just use JSonEncode and Decode, its like strings e.e |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2015 12:27 AM |
| No, don't add parenthesis. |
|
|
| Report Abuse |
|
|
Diitto
|
  |
| Joined: 08 Mar 2011 |
| Total Posts: 92 |
|
|
| 10 Jul 2015 12:28 AM |
NO YOU DO NOT NEED THOSE PARENTHESIS SILLY FOOL
|
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jul 2015 12:28 AM |
then explain it please.
game.OnClose = saveTable
just doesent make sense. how can the game closing be a variable? is this a troll? |
|
|
| Report Abuse |
|
|
KoreanBBQ
|
  |
| Joined: 06 Mar 2015 |
| Total Posts: 1436 |
|
|
| 10 Jul 2015 12:29 AM |
| isnt storing a table like byte consumming or idk |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 10 Jul 2015 12:29 AM |
| ok so whats happening here kevkev is that you're straight up telling us to make scripts. we are not your slaves, sorry. go read the wiki or try lualearners.org and then come back when you're actually stuck and have an actual script. |
|
|
| Report Abuse |
|
|
|
| 10 Jul 2015 12:30 AM |
| Are you a troll? saveTable is a function. |
|
|
| Report Abuse |
|
|
KoreanBBQ
|
  |
| Joined: 06 Mar 2015 |
| Total Posts: 1436 |
|
|
| 10 Jul 2015 12:31 AM |
| just game.Close, where .Close is the event fired when the place is exited |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jul 2015 12:31 AM |
heres my script lolb
local datastoreService = game:GetService("DataStoreService") local dataStore = datastoreService:GetDataStore("SomeDatastore")
local tableKey = "keyForOurTable"
local ourTable = nil
function saveTable() if ourTable == nil then return end dataStore:SetAsync(tableKey, ourTable) end
function getTable() local tab = dataStore:GetAsync(tableKey) return tab end
ourTable = getTable()
game.OnClose = saveTable
while true do wait(60) saveTable() end
The problem is it never makes the table in the first place , like it never says
tab = {}
And Im having troulbe understanding. this line.
game.OnClose = saveTable
So now can you help?
:P |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 10 Jul 2015 12:33 AM |
| you're so funny. being a smartass about it makes us want to help you so much more too! |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jul 2015 12:35 AM |
"language"
-Captain America |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
| |
|