Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 30 Oct 2017 04:08 PM |
I'm a noob to data stores and this is not working, what did I do wrong.. the output doesn't give me an error and it doesn't even print what it's supposed to :PP
--Data store local DataStoreService = game:GetService("DataStoreService") local PlayerStats = DataStoreService:GetDataStore("PlayerStats") local Key = player.userId player:WaitForDataReady() local stats = player.InfoStore:GetChildren() pcall(function() for i = 1,#stats do print(stats[i].Name.." " ..stats[i].Value) stats[i].Value = PlayerStats:GetAsync(Key) end end)
|
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
dj7679
|
  |
| Joined: 11 Jun 2013 |
| Total Posts: 307 |
|
| |
|
|
| 30 Oct 2017 05:14 PM |
| why are you using waitfordataready it doesn't do anything |
|
|
| Report Abuse |
|
|
Linxesis
|
  |
| Joined: 19 Aug 2014 |
| Total Posts: 325 |
|
|
| 30 Oct 2017 05:35 PM |
Put a print on every other line, figure out when the printing stops for example print("Work1") line1.. line2.. print("Work2") line3... line...4 print("Work3")
|
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
|
| 30 Oct 2017 06:38 PM |
| Listen to that dudes advice. Use print and see when it stops printing. They come back and ask. |
|
|
| Report Abuse |
|
|
Linxesis
|
  |
| Joined: 19 Aug 2014 |
| Total Posts: 325 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 30 Oct 2017 06:46 PM |
| Okay I will do that. :-----) |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 30 Oct 2017 06:47 PM |
It prints up until "work3" then stops
local Key = "player- "..player.userId local DataStoreService = game:GetService("DataStoreService") local PlayerStats = DataStoreService:GetDataStore("PlayerStats",Key)
local stats = player.InfoStore:GetChildren() print("work1") pcall(function() print("work2") for i = 1,#stats do print("work3") print(stats[i].Name.." " ..stats[i].Value) print("work4") stats[i].Value = PlayerStats:GetAsync(Key) end end) |
|
|
| Report Abuse |
|
|
Linxesis
|
  |
| Joined: 19 Aug 2014 |
| Total Posts: 325 |
|
|
| 30 Oct 2017 06:48 PM |
wonderful also add this at the top of the script it will wait 5 sec before it closes, witch will give it time to save
Line of script: game:BindToClose(function() wait(5) end)
|
|
|
| Report Abuse |
|
|
Linxesis
|
  |
| Joined: 19 Aug 2014 |
| Total Posts: 325 |
|
|
| 30 Oct 2017 06:50 PM |
does print3 works or not??
|
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 30 Oct 2017 06:52 PM |
It prints up until "work3" then stops
|
|
|
| Report Abuse |
|
|
Linxesis
|
  |
| Joined: 19 Aug 2014 |
| Total Posts: 325 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
Linxesis
|
  |
| Joined: 19 Aug 2014 |
| Total Posts: 325 |
|
|
| 30 Oct 2017 07:03 PM |
print the #stats, they may not be anything
write before the print(for[i]...) print(#stast[1])
|
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 30 Oct 2017 07:14 PM |
| I printed #stats and it worked. Output printed "22". So why is it not printing the names and values? |
|
|
| Report Abuse |
|
|
K7Q
|
  |
| Joined: 23 Mar 2013 |
| Total Posts: 5546 |
|
|
| 30 Oct 2017 07:14 PM |
instead of :
for i = 1,#stats do
try:
for i = 1,#stats, 1 do
it saved me once for negative numbers |
|
|
| Report Abuse |
|
|
Linxesis
|
  |
| Joined: 19 Aug 2014 |
| Total Posts: 325 |
|
|
| 30 Oct 2017 07:17 PM |
sometimes for i,v in pairs() do and for i,#whatever do will not do anything if the table is only nil values. I learned this the had way in my game when i was making my own matchmaking
|
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 30 Oct 2017 07:26 PM |
stats[i].Value = PlayerStats:GetAsync(Key)
bad argument #3 to 'Value' (string expected, got nil) |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 30 Oct 2017 07:29 PM |
| Oh well time for more tutorials |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 30 Oct 2017 08:24 PM |
OK here is an UPDATED version of the script but it's STILL not saving. D:
local Key = "player- "..player.userId local DataStoreService = game:GetService("DataStoreService") local PlayerStats = DataStoreService:GetDataStore("PlayerStats")
FirstTime = Instance.new("BoolValue",InfoStore) FirstTime.Name = "FirstTime" FirstTime.Value = PlayerStats:GetAsync(Key) or true PlayerStats:SetAsync(Key, player.InfoStore.FirstTime.Value)
player.InfoStore.FirstTime.Changed:connect(function() PlayerStats:SetAsync(Key,player.InfoStore.FirstTime.Value) end) |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|