of     1   

ForeverDev
#130862864Wednesday, April 16, 2014 12:24 AM GMT

I'm using data persistence to load a GUI onto a player's screen when they spawn. It is used like this: game.Players.PlayerAdded:connect(function(plr) plr:WaitForDataReady() plr.CharacterAdded:connect(function() --load gui and stuff end) end) The problem is CharacterAdded is not firing the first time a player spawns. However, if you reset your character, it will fire and load the GUI with no problems. Does anyone know why this is happening?
ForeverDev
#130863056Wednesday, April 16, 2014 12:25 AM GMT

Never mind, I figured it out. The WaitForDataReady was yielding the script and causing it to not recognize the first spawn.
cntkillme
#130863073Wednesday, April 16, 2014 12:26 AM GMT

Probably because by the time the dataready property is ready, the character has been added. If you don't plan on using Data Persistence then remove that part
ForeverDev
#130863335Wednesday, April 16, 2014 12:28 AM GMT

@cnt The problem is I am using Data Persistence. Taking away the wait for data makes it work, I just hope it doesn't cause any load issues :/
ForeverDev
#130863475Wednesday, April 16, 2014 12:29 AM GMT

Yeah, taking away the WaitForDataReady is causing issues. What should I do? :/
Sasayaki
#130863535Wednesday, April 16, 2014 12:30 AM GMT

Put that code inside the CharacterAdded code.
robokittydestroyer
#130863562Wednesday, April 16, 2014 12:30 AM GMT

Maybe put the WaitForDataReady inside the CharacterAdded?
ForeverDev
#130863609Wednesday, April 16, 2014 12:31 AM GMT

Oh, LOL.
cntkillme
#130863620Wednesday, April 16, 2014 12:31 AM GMT

Just do this: game.Players.PlayerAdded:connect(function(plr) plr:WaitForDataReady() if plr.Character then --load gui and stuff end plr.CharacterAdded:connect(function() --load gui and stuff end) end) or something more efficient, or course
robokittydestroyer
#130863641Wednesday, April 16, 2014 12:31 AM GMT

lol, ninja'd me.
cntkillme
#130863705Wednesday, April 16, 2014 12:31 AM GMT

Nah, it would be better to do it only the first time they respawn otherwise you are just being inefficient.
ForeverDev
#130863869Wednesday, April 16, 2014 12:33 AM GMT

@cnt Making it check the first time doesn't work because the character loads first. I don't think it will be very inefficient, because the game doesn't involve death unless the player resets.
Private1stBr_ss
#130864062Wednesday, April 16, 2014 12:35 AM GMT

There's ways around these issues. For example: Breakable: game.Players.PlayerAdded:connect(function(p) -- If player joins early, no print. print (p.Name .. " arrived") --stuff game.Players.CharacterAdded:connect(function(c) -- Same here, but with characters print (c.Name .. " respawned") end) end) This is a little better, because it connect already added players/characters: function charAdded(c) print (c.Name .. " respawned") end function newPlayer(p) print (p.Name .. " arrived") --stuff game.Players.CharacterAdded:connect(charAdded) if p.Character then charAdded(p.Character) end game.Players.PlayerAdded:connect(newPlayer) for _,v in pairs (game.Players:GetChildren()) do newPlayer(v) end Something like that :P
Sasayaki
#130864404Wednesday, April 16, 2014 12:38 AM GMT

Best solution is simply using DataStore over DataPersistance....
cntkillme
#130864822Wednesday, April 16, 2014 12:42 AM GMT

'Making it check the first time doesn't work because the character loads first. I don't think it will be very inefficient, because the game doesn't involve death unless the player resets.' That's why I told you to check whether the character has already been added, or even better: game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function() --load gui and stuff end) plr:WaitForDataReady() end) If you plan on only saving stuff after And it's unneeded calling of a function, which is inefficient--negligibly but still, inefficient
ForeverDev
#130864883Wednesday, April 16, 2014 12:42 AM GMT

^wazap I'm a noob and have never used DataStore. I got the load to work and I don't really feel like changing my method :P

    of     1