Nulerite
|
  |
| Joined: 08 Mar 2016 |
| Total Posts: 231 |
|
|
| 12 Mar 2016 11:54 AM |
game.OnClose = function() for _, player in pairs(game.Players:GetPlayers()) do spawn(function() saveData(player) end) end end
vs.
game.OnClose = function() for _, player in pairs(game.Players:GetPlayers()) do saveData(player) end end
I have not seen a definitive answer on whether or not saving data with a new thread will actually save faster. Will it?
|
|
|
| Report Abuse |
|
|
KLGA
|
  |
| Joined: 19 Apr 2014 |
| Total Posts: 2571 |
|
|
| 12 Mar 2016 12:04 PM |
| I'm assuming it'd be faster with using spawn. Instead of running each function one after another, they are all run simultaneously. |
|
|
| Report Abuse |
|
|
Fabunil
|
  |
| Joined: 25 Oct 2013 |
| Total Posts: 4325 |
|
|
| 12 Mar 2016 12:08 PM |
| Unless the saving methods yield the thread until they are fully executed I would say no. |
|
|
| Report Abuse |
|
|
|
| 12 Mar 2016 12:09 PM |
when OnClose is invoked there will be no players in game just make OnClose yield for a bit while saving with PlayerRemoving
Recommended username: ToughRay_revenge
|
|
|
| Report Abuse |
|
|
|
| 12 Mar 2016 12:32 PM |
game.OnClose = function() for _, player in pairs(game.Players:GetPlayers()) do spawn(function() saveData(player) end) end wait(30) end |
|
|
| Report Abuse |
|
|
Nulerite
|
  |
| Joined: 08 Mar 2016 |
| Total Posts: 231 |
|
|
| 12 Mar 2016 12:48 PM |
Why the wait(30)...why on earth would you add a wait(30)...which wouldn't even get to complete.
|
|
|
| Report Abuse |
|
|
Fabunil
|
  |
| Joined: 25 Oct 2013 |
| Total Posts: 4325 |
|
|
| 12 Mar 2016 05:11 PM |
^Without the wait(30) the function might end early and the game would shut down before the saves are completed.
|
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 12 Mar 2016 05:25 PM |
Roblox "threads" don't "run simultaneously", only one is running at a time, use the second option.
|
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 12 Mar 2016 05:27 PM |
| Spawn doesn't start a new thread. In fact, using spawn() in this situation is counterintuitive. |
|
|
| Report Abuse |
|
|
Nulerite
|
  |
| Joined: 08 Mar 2016 |
| Total Posts: 231 |
|
|
| 12 Mar 2016 07:41 PM |
Oh I forgot he was calling spawn() in there so yeah it would
|
|
|
| Report Abuse |
|
|