Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 03 Aug 2013 12:35 PM |
I've been trying to fix this leaderboard for days.. Nothing seems to happen. It doesn't clone any IntValue into the player..
function onPlayerEntered(newPlayer) local m = Instance.new("IntValue",newPlayer) m.Name = "Minutes" m.Value = 0 newPlayer:WaitForDataReady() m.Value = newPlayer:LoadNumber("Minutes") or 0 m.Changed:connect(function() newPlayer:SaveNumber("Minutes",m.Value) end) coroutine.resume(coroutine.create(function() while true do wait(60) m.Value = m.Value + 1 end end)) end
game.Players.PlayerAdded:connect(onPlayerEntered) |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
| |
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
| |
|
|
| 03 Aug 2013 01:01 PM |
| Have you tried testing it online? Here's an idea. Add a GUI to your place that turns green if the player has the Value, and red if not. Upload it as your place, and test it online. I didn't see any big errors, so this is the best idea I've got. |
|
|
| Report Abuse |
|
|
slingy11
|
  |
| Joined: 29 May 2011 |
| Total Posts: 60 |
|
|
| 03 Aug 2013 01:05 PM |
| I've had this problem as well. I think when the function goes, the player isn't there so it doesn't put it anywhere. How about checking if the value exists every few seconds or frames and if it's not existent you make it again. That works for me, but I bet there's a better way somewhere |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 03 Aug 2013 01:17 PM |
I've tested it online, where if the value does exist, the text says "Exists" and if it doesn't, it says "Error", and it only shows "Error".
Will this do the trick? repeat wait() until newPlayer and newPlayer.Character |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 03 Aug 2013 01:20 PM |
Should I do this?
repeat local m = Instance.new("IntValue",newPlayer) m.Name = "Minutes" m.Value = 0 until newPlayer:FindFirstChild("Minutes") |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
| |
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
| |
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
| |
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
| |
|
slingy11
|
  |
| Joined: 29 May 2011 |
| Total Posts: 60 |
|
|
| 03 Aug 2013 04:46 PM |
| I guess that works, seems like a great idea. I'm going to try it out with my game. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 03 Aug 2013 05:08 PM |
Try this: (LOL I helped you with this leaderboard c:)
function onPlayerEntered(newPlayer) repeat wait(0) until newPlayer
local m = Instance.new("IntValue",newPlayer) m.Name = "Minutes" m.Value = 0
newPlayer:WaitForDataReady()
m.Value = newPlayer:LoadNumber("Minutes") or 0
m.Changed:connect(function() newPlayer:SaveNumber("Minutes",m.Value) end)
while wait(60) do m.Value = m.Value + 1 end
end
game.Players.PlayerAdded:connect(onPlayerEntered) |
|
|
| Report Abuse |
|
|
slingy11
|
  |
| Joined: 29 May 2011 |
| Total Posts: 60 |
|
| |
|
Vector2D
|
  |
| Joined: 11 May 2013 |
| Total Posts: 195 |
|
|
| 03 Aug 2013 05:24 PM |
game:GetService('Players')['PlayerAdded']:connect(function(player) player:WaitForDataReady();
if (not player:LoadInstance('leaderstats')) then Instance.new('Model', player).Name = 'leaderstats'; Instance.new('IntValue', player).Name = 'Minutes'; end;
while wait(60) do if (player) then player.leaderstats.Minutes.Value = player.leaderstats.Minutes.Value + 1; player:SaveInstance('leaderstats', player.leaderstats); else break; end; end; end); |
|
|
| Report Abuse |
|
|