of     1   

Lord_Narwhal
#139837756Thursday, July 10, 2014 4:01 AM GMT

I'm not sure why, it's not printing that a player has been found. game.Players.PlayerAdded:connect(function(player) repeat wait() until player~=nil print("Player found!") local Exp = Instance.new("IntValue",plr) Exp.Name = "Exp" Exp.Value = 0 local ExpNeeded = Instance.new("IntValue",plr) ExpNeeded.Name = "ExpNeeded" ExpNeeded.Value = 120 local lvl = Instance.new("IntValue",plr) lvl.Name = "Level" lvl.Value = 1 local cash = Instance.new("IntValue",plr) cash.Name = "Cash" cash.Value = 0 local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Values") player:WaitForChild("Exp") player:WaitForChild("ExpNeeded") player:WaitForChild("Level") player:WaitForChild("Cash") wait(1) Exp.Value = datastore:GetAsync(Exp.Name) ExpNeeded.Value = datastore:GetAsync(ExpNeeded.Name) Level.Value = datastore:GetAsync(Level.Name) Cash.Value = datastore:GetAsync(Cash.Name) print("Stats loaded") end)
ZeroSpectrum
#139838181Thursday, July 10, 2014 4:05 AM GMT

The event fires when a player is "added" and not "loading", so you don't need to worry about if the player has loaded or not. I think this repeat may run on endlessly. Make sure you're doing this in online mode, which you probably already aware of. game.Players.PlayerAdded:connect(function(player) --repeat wait() until player~=nil print("Player found!")
Lord_Narwhal
#139838592Thursday, July 10, 2014 4:09 AM GMT

@Above did not work
KEVEKEV77
#139838808Thursday, July 10, 2014 4:11 AM GMT

AT start if player:GetDataReady() then
Lord_Narwhal
#139838941Thursday, July 10, 2014 4:13 AM GMT

ok i fixed it up a bit here's what it is now game.Players.PlayerAdded:connect(function(plr) if plr:GetDataReady() then print("Player found!") local Exp = Instance.new("IntValue",plr) Exp.Name = "Exp" Exp.Value = 0 local ExpNeeded = Instance.new("IntValue",plr) ExpNeeded.Name = "ExpNeeded" ExpNeeded.Value = 120 local lvl = Instance.new("IntValue",plr) lvl.Name = "Level" lvl.Value = 1 local cash = Instance.new("IntValue",plr) cash.Name = "Cash" cash.Value = 0 local datastore = game:GetService("DataStoreService"):GetDataStore(plr.Name.."Values") plr:WaitForChild("Exp") plr:WaitForChild("ExpNeeded") plr:WaitForChild("Level") plr:WaitForChild("Cash") wait(1) Exp.Value = datastore:GetAsync(Exp.Name) ExpNeeded.Value = datastore:GetAsync(ExpNeeded.Name) Level.Value = datastore:GetAsync(Level.Name) Cash.Value = datastore:GetAsync(Cash.Name) print("Stats loaded") end end)
Lord_Narwhal
#139839308Thursday, July 10, 2014 4:16 AM GMT

i changed that line to WaitForDataReady still isn't printing anything
Lord_Narwhal
#139839968Thursday, July 10, 2014 4:25 AM GMT

here's the entire script, if it's affecting it in some way while wait(60) do local m = Instance.new("Hint",Workspace) m.Text = "Saving stats.." for i,v in pairs(game.Players:GetPlayers()) do local datastore = game:GetService("DataStoreService"):GetDataStore(v.Name.."Values") local Exp = v:WaitForChild("Exp") local ExpNeeded = v:WaitForChild("ExpNeeded") local Level = v:WaitForChild("Level") local Cash = v:WaitForChild("Cash") datastore:SetAsync(Exp.Name, Exp.Value) datastore:SetAsync(Cash.Name,Cash.Value) datastore:SetAsync(ExpNeeded.Name,ExpNeeded.Value) datastore:SetAsync(Level.Name,Level.Value) print("Stats successfully saved") end end game.Players.PlayerAdded:connect(function(plr) plr:WaitForDataReady() print("Player found!") local Exp = Instance.new("IntValue",plr) Exp.Name = "Exp" Exp.Value = 0 local ExpNeeded = Instance.new("IntValue",plr) ExpNeeded.Name = "ExpNeeded" ExpNeeded.Value = 120 local lvl = Instance.new("IntValue",plr) lvl.Name = "Level" lvl.Value = 1 local cash = Instance.new("IntValue",plr) cash.Name = "Cash" cash.Value = 0 local datastore = game:GetService("DataStoreService"):GetDataStore(plr.Name.."Values") plr:WaitForChild("Exp") plr:WaitForChild("ExpNeeded") plr:WaitForChild("Level") plr:WaitForChild("Cash") wait(1) Exp.Value = datastore:GetAsync(Exp.Name) ExpNeeded.Value = datastore:GetAsync(ExpNeeded.Name) Level.Value = datastore:GetAsync(Level.Name) Cash.Value = datastore:GetAsync(Cash.Name) print("Stats loaded") end)
robloxthebook
#139846513Thursday, July 10, 2014 5:30 AM GMT

If you're testing this by "Play Solo", you're original script may be right. If you're actually doing this you should start a server with one player. If you still don't understand, too bad.
Lord_Narwhal
#139846820Thursday, July 10, 2014 5:32 AM GMT

"If you still don't understand, too bad." well you're no help so does anyone know why the PlayerAdded is not working i'm testing it at my actual place, not playsolo or a server it's breaking all of my other scripts that use the values can someone please help
Lord_Narwhal
#139889662Thursday, July 10, 2014 5:45 PM GMT

bump
DataStore
#139889869Thursday, July 10, 2014 5:47 PM GMT

Put the while loop at the end of the script.
e_Scriph
#139889909Thursday, July 10, 2014 5:47 PM GMT

... Press f9 BOOM mind blown. you will see the text in dev console - xXScriptzXx
Lord_Narwhal
#139890083Thursday, July 10, 2014 5:49 PM GMT

i am using f9
Lord_Narwhal
#139890238Thursday, July 10, 2014 5:51 PM GMT

"Put the while loop at the end of the script." where exactly
DataStore
#139890506Thursday, July 10, 2014 5:53 PM GMT

After any functions you're expecting to run. The while loop, as it currently stands, is stopping everything else from running, which it will continue to do until it's the last thing to be ran, or the loop is broken.
Lord_Narwhal
#139891709Thursday, July 10, 2014 6:05 PM GMT

thanks a lot, everything works now

    of     1