KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jun 2015 01:49 PM |
This aint on the wiki, so thats why I come before you.
I have a table. I want the contents to save and load back into it when a player joins and saves when he / she exits(Can u save using the playerLeave event? Since he/she is gone, can i still save it that way?) this is what i have so far, so u can work off of it.
Tab = {};
game.Players.PlayerAdded:connect(function(plr)\ local DataStore = game:GetService("DataStoreService"):GetDataStore("Tables"); for i,v in pairs(Tab) do DataStore:UpdateAsync(key, function(old) local new = old or {}--make a new table if theyre aint one return new end) end end)
Btw, I learned of DataStore yesterday, so pardon me not knowing what to do
|
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
| |
|
|
| 10 Jun 2015 02:17 PM |
local datastore = game:GetService("DataStoreService"):GetDataStore("Kills")
game.Players.PlayerAdded:connet(function(player) local kills = datastore:GetAsync(player.Name) if kills == nil then datastore:SetAsync(player.Name,0) else --Do whatchu want it here end end)
|
|
|
| Report Abuse |
|
|
|
| 10 Jun 2015 02:17 PM |
| That doesn't even have a table in it Vineyard. Lmao. |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jun 2015 02:24 PM |
| stop cussing, and plz fix his script? |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2015 02:24 PM |
I was going to help you, then you somehow got the idea that I've been cussing.
So no. |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jun 2015 02:26 PM |
| well alright, somene else? |
|
|
| Report Abuse |
|
|
Tinfold
|
  |
| Joined: 11 May 2010 |
| Total Posts: 1435 |
|
|
| 10 Jun 2015 02:28 PM |
| You can't save a table directly. The only way you could save and load the table itself is by using the JSON functions. |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jun 2015 02:36 PM |
| please tell me how to do that |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jun 2015 03:39 PM |
Well sorry for affending you, but i count "lmo" (with an a) as a cuss. Please help! |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 10 Jun 2015 03:41 PM |
laughing my ass off
is not the same as
you are an ass---- |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jun 2015 03:43 PM |
| I think its gross still, but please just help. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 10 Jun 2015 03:44 PM |
Lmfao. Get offended.
Use PlayerRemoving(Instance Player) |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 10 Jun 2015 04:00 PM |
U are so evil. Get out.
I KNOW WHAT PLAYERREMOVING IS STUPID |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 10 Jun 2015 04:03 PM |
| You should have had a comma between 'is' and 'stupid' c: |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
| |
|
|
| 10 Jun 2015 04:08 PM |
a) You can save a table with DataStore b) Your script is trying to iterate through nothing. Nothing is going to happen, and the loop will never run, because the table is nil. |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 10 Jun 2015 04:08 PM |
| I did I told you what you should use. If you need more help, you can also use DataStore:SetAsync(string Key, var Data) |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2015 04:42 PM |
Hope this works..
local PlayerData = {Cash = 100; Level = 1;} --etc local DataStore = game:GetService("DataStoreService"):GetDataStore("Tables"); game.Players.PlayerAdded:connect(function(plr) local LoadedData = DataStore:GetAsync(plr.userId) if LoadedData ~= nil then for i,v in pairs(LoadedData) do PlayerData[i] = LoadedData[v] end end end)
game.Players.PlayerRemoving:connect(function(plr) DataStore:SetAsync(plr.userId, PlayerData) end) |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 11 Jun 2015 02:59 PM |
i know why it doesent work, (it doesent)
U forgot to say if it is nil, which it always is the first time!
So...
if LoadedData == nil then DataStore:SetAsync(plr.userId, PlayerData) end |
|
|
| Report Abuse |
|
|