of     1   

Raildex
#183385157Thursday, February 11, 2016 7:24 PM GMT

so my script here is having a problem when the player leaves. It makes it to the data ready print but then doesnt get any farther than that. Do you see anything wrong that im doing? local datastore = game:GetService("DataStoreService"):GetDataStore("PlayerStats") print("cash datastore created") game.Players.PlayerAdded:connect(function(newPlayer) print("EnteredGame") --newPlayer:WaitForDataReady() print("data ready") local stats2 = newPlayer:WaitForChild("leaderstats") stats2.Cash.Value = datastore:GetAsync(newPlayer.userId .. "Cash") print("Loaded stats") wait(1) datastore:SetAsync(newPlayer.userId .. "Cash", stats2.Cash.Value) print("Saved stats") end) game.Players.PlayerRemoving:connect(function(player) print("ExitedGame") --player:WaitForDataReady() print("data ready") --wait(2) local stats = player.leaderstats print("got leaderstats") datastore:SetAsync(player.userId .. "Cash", stats.Cash.Value) print("Saved stats") end) game.OnClose = function() print("begin game close") wait(2) print("end game close") end
128Gigabytes
#183385680Thursday, February 11, 2016 7:40 PM GMT

Is there any output?
RulerOfTheFree
#183389288Thursday, February 11, 2016 8:54 PM GMT

If you put a print between these two, local stats2 = newPlayer:WaitForChild("leaderstats") stats2.Cash.Value = datastore:GetAsync(newPlayer.userId .. "Cash") , it probably won't print. If it doesn't, it's not finding "leaderstats", so you need to create it.
Raildex
#183392672Thursday, February 11, 2016 9:53 PM GMT

The player added function wasnt what was wrong, its the second function. I had already done that

    of     1