Cybertek
|
  |
| Joined: 29 May 2014 |
| Total Posts: 18 |
|
|
| 17 Jul 2017 12:04 PM |
local dss=game:GetService("DataStoreService") local player=game:GetService("Players") local HttpService=game:GetService("HttpService")
game.Players.PlayerAdded:connect(function(player) local scope="player_"..player.UserId local dsl=dss:GetDataStore("TableOfContents",scope) local stats={} stats.Endurance=10 stats.Hunger=100 end)
How can I store the table 'stats' into the datastore and then do a print(value of Hunger) when the player leaves the game? |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2017 12:07 PM |
| it's better to define your variable ### outside of playeradded since you might be using it in playerremoving for saving data |
|
|
| Report Abuse |
|
|
LaeMVP
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
|
| 17 Jul 2017 12:08 PM |
[1] = Lua doesn't get triggered by white space, consider adding a few spaces so your code is a little more readable; [2] = Connect not connect, the method connect is deprecated in favor of Connect; [3] = What does giving the scope arg of GetDataStore do? I've never used it and I've never had any problems. [4] = You could save an array to a datastore by doing, DataStoreExample:SetAsync(StringKey,{}) (That's just an example) [5] = What are you feelings on Tuscany, I think it's a rather enjoyable location. |
|
|
| Report Abuse |
|
|
Cybertek
|
  |
| Joined: 29 May 2014 |
| Total Posts: 18 |
|
|
| 17 Jul 2017 12:10 PM |
| no I want the table to be stored when the player connects, and when the player is removed I only want to print a specific row from the table, aka "Hunger". |
|
|
| Report Abuse |
|
|
Cybertek
|
  |
| Joined: 29 May 2014 |
| Total Posts: 18 |
|
| |
|