Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 22 Dec 2014 11:02 PM |
I get no output using this code, what am I doing wrong?
local ds = game:GetService("DataStoreService"):GetDataStore("CardsSave0.1") PlayersCards = ds:GetAsync("Cards0.1")
game.Players.PlayerAdded:connect(function(Plr) if ds:GetAsync(Plr.userId,PlayersCards) == nil then print ("no cards to load") else for i, v in pairs(PlayersCards) do local val = game.Lighting.Cards[v.Name]:clone() val.Parent = game.Players[Plr.Name].Cards end end end)
game.Players.PlayerRemoving:connect(function(Plr) for i, v in pairs(Plr.Cards:GetChildren()) do table.insert(PlayersCards,v.Name) end if ds:GetAsync(Plr.userId,PlayersCards) == nil then ds:SetAsync(Plr.userId,PlayersCards) else ds:UpdateAsync(Plr.userId,function() return PlayersCards end) end end) |
|
|
| Report Abuse |
|
|
KLGA
|
  |
| Joined: 19 Apr 2014 |
| Total Posts: 2571 |
|
|
| 22 Dec 2014 11:04 PM |
wait what are you doing what is point of the table you dont even use it ever |
|
|
| Report Abuse |
|
|
ruon123
|
  |
| Joined: 22 Jan 2011 |
| Total Posts: 325 |
|
|
| 22 Dec 2014 11:13 PM |
@KLGA i dont think you understand the point of DataStores |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 22 Dec 2014 11:25 PM |
Bump Please -_- I can never get any help when I ask about DataStore I honestly need this tonight... |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 22 Dec 2014 11:30 PM |
| Make sure everything is actually running by adding print statements everywhere. Then tell us where it stops, if it stops, |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 22 Dec 2014 11:40 PM |
| I had an issue with the adding player it was something like line 5 something was nil and fixed that, I think it has something to do with the removing of player seeing as I get no output. |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 22 Dec 2014 11:47 PM |
I get this from the prints below. Started Player Added to Game No cards founds Player has entered The End!
PlayerAdded seems to work. It's when the player leaves...
local ds = game:GetService("DataStoreService"):GetDataStore("CardsSave0.1") PlayersCards = ds:GetAsync("Cards0.1") print("Started") game.Players.PlayerAdded:connect(function(Plr) print("Player Added to Game") if ds:GetAsync(Plr.userId,PlayersCards) == nil then print ("No cards found") else for i, v in pairs(PlayersCards) do print("Cards found") local val = game.Lighting.Cards[v.Name]:clone() val.Parent = game.Players[Plr.Name].Cards end end end) print("Player has entered") game.Players.PlayerRemoving:connect(function(Plr) for i, v in pairs(Plr.Cards:GetChildren()) do table.insert(PlayersCards,v.Name) end if ds:GetAsync(Plr.userId,PlayersCards) == nil then ds:SetAsync(Plr.userId,PlayersCards) else ds:UpdateAsync(Plr.userId,function() return PlayersCards end) end end) print("The End!") |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 22 Dec 2014 11:49 PM |
| Replace the PlayerRemoving with ChildRemoved then. |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 23 Dec 2014 04:42 AM |
if ds:GetAsync(Plr.userId,PlayersCards) == nil then print ("no cards to load") else for i, v in pairs(PlayersCards) do
Mm no. |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 23 Dec 2014 11:05 AM |
Ok it's not like I'm asking for someone to make a whole new script for me, just correct my errors please -_-
Besides with leaderboards this is the first time I've used DataStore and got this far... Just asking for some help. |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 23 Dec 2014 12:20 PM |
?
-Codys4x4 - Send me a trade. |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 23 Dec 2014 01:10 PM |
ogm
-Codys4x4 (C4) - Send me a trade. |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
|
| 23 Dec 2014 02:42 PM |
kk
-Codys4x4 (C4) - Send me a trade. |
|
|
| Report Abuse |
|
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|
Codys4x4
|
  |
| Joined: 14 Oct 2006 |
| Total Posts: 2312 |
|
| |
|