Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:09 PM |
Why won't the leaderboards work? When I test play solo, I don't see the IntValue's that's supposed to be inside the player. Also, there is no IntValue called "leaderboard" there's only "Seconds", "Minutes", "Hours". And when I made a GUI that's supposed to tell how long the player has played for, the output says that there's no existing "Hours" and "Seconds" and "Minutes".
function onPlayerEntered(newPlayer)
local sec = Instance.new("IntValue",newPlayer) sec.Name = "Seconds" sec.Value = 0 local min = Instance.new("IntValue",newPlayer) min.Name = "Minutes" min.Value = 0 local hr = Instance.new("IntValue",newPlayer) hr.Name = "Hours" hr.Value = 0
end
game.Players.ChildAdded:connect(onPlayerEntered) |
|
|
| Report Abuse |
|
|
ZachBloxx
|
  |
| Joined: 26 Jun 2013 |
| Total Posts: 2833 |
|
|
| 02 Aug 2013 03:13 PM |
| Well there is no IntValue called 'leaderboard' because you never made one in the script. Also I don't think the PlayerAdded or ChildAdded events work in Test mode. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:15 PM |
| I know, I said that there was no IntValue called "leaderboard". And I tested the real game and nothing happens to the timer.. It stays at 0:0:0 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2013 03:17 PM |
| You need a loop to increase the value |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:18 PM |
Here's the entire script:
function onPlayerEntered(newPlayer)
local sec = Instance.new("IntValue",newPlayer) sec.Name = "Seconds" sec.Value = 0 local min = Instance.new("IntValue",newPlayer) min.Name = "Minutes" min.Value = 0 local hr = Instance.new("IntValue",newPlayer) hr.Name = "Hours" hr.Value = 0 repeat wait() until newPlayer.DataReady == true sec.Value = newPlayer:LoadNumber("Seconds") min.Value = newPlayer:LoadNumber("Minutes") hr.Value = newPlayer:LoadNumber("Hours") while true do wait(1) if min.Value == 60 then hr.Value = hr.Value + 1 min.Value = 0 sec.Value = 0 elseif sec.Value == 60 then min.Value = min.Value + 1 sec.Value = 0 elseif sec.Value < 60 then sec.Value = sec.Value + 1 end end end
function Save(plr) plr:SaveNumber("Seconds",plr.Seconds.Value) plr:SaveNumber("Minutes",plr.Minutes.Value) plr:SaveNumber("Hours",plr.Hours.Value) end
game.Players.PlayerRemoving:connect(Save) game.Players.ChildAdded:connect(onPlayerEntered) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2013 03:20 PM |
Don't save when people leave the game, it's gltichy at best.
Why "repeat wait() until newPlayer.DataReady == true" when you can: "newPlayer:WaitForDataReady()" |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:21 PM |
| Switched it to WaitForDataReady, and if I don't save when people leave the game, how can I save? |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:22 PM |
| Leaderboard still doesn't work.. Bump |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2013 03:22 PM |
changed events
(Value.Changed:connect(function() Player:SaveNumber(Value, val) end)
Also, you can't save and load data from studio modes (play solo, start player) |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:42 PM |
| Which part of the leaderboard should I add it into? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:44 PM |
| I mean like, where do I put it? After the while true do or before? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:48 PM |
Like this?
function onPlayerEntered(newPlayer)
local sec = Instance.new("IntValue",newPlayer) sec.Name = "Seconds" sec.Value = 0 local min = Instance.new("IntValue",newPlayer) min.Name = "Minutes" min.Value = 0 local hr = Instance.new("IntValue",newPlayer) hr.Name = "Hours" hr.Value = 0 newPlayer:WaitForDataReady() sec.Value = newPlayer:LoadNumber("Seconds") min.Value = newPlayer:LoadNumber("Minutes") hr.Value = newPlayer:LoadNumber("Hours") sec.Changed:connect(function() newPlayer:SaveNumber("Seconds",sec.Value) end) min.Changed:connect(function() newPlayer:SaveNumber("Minutes",min.Value) end) hr.Changed:connect(function() newPlayer:SaveNumber("Hours",hr.Value) end) while true do wait(1) if min.Value == 60 then hr.Value = hr.Value + 1 min.Value = 0 sec.Value = 0 elseif sec.Value == 60 then min.Value = min.Value + 1 sec.Value = 0 elseif sec.Value < 60 then sec.Value = sec.Value + 1 end end end
game.Players.ChildAdded:connect(onPlayerEntered) |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2013 03:49 PM |
Perfect, but for the declaring parts where you do:
= newPlayer:LoadNumber("Seconds") you should do = newPlayer:LoadNumber("Seconds") or 0
because you can't add to nil |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:50 PM |
| Got it, now going to test it. |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:51 PM |
BTW, this is a script inside a GUI that shows the time. Is it correct?
repeat wait() until game.Players.LocalPlayer
local hr = game.Players.LocalPlayer.Hours.Value local min = game.Players.LocalPlayer.Minutes.Value local sec = game.Players.LocalPlayer.Seconds.Value
while wait() do if sec < 10 and min < 10 and hr < 10 then script.Parent.Text = "Time Played: 0"..hr..":0"..min..":0"..sec elseif sec > 10 and min > 10 and hr > 10 then script.Parent.Text = "Time Played: "..hr..":"..min..":"..sec elseif sec < 10 and min < 10 and hr > 10 then script.Parent.Text = "Time Played: "..hr..":0"..min..":0"..sec elseif sec < 10 and hr < 10 and min > 10 then script.Parent.Text = "Time Played: 0"..hr..":"..min..":0"..sec elseif min < 10 and hr < 10 and sec > 10 then script.Parent.Text = "Time Played: 0"..hr..":0"..min..":"..sec elseif min > 10 and sec > 10 and hr < 10 then script.Parent.Text = "Time Played: 0"..hr..":"..min..":"..sec elseif hr > 10 and sec > 10 and min < 10 then script.Parent.Text = "Time Played: "..hr..":0"..min..":"..sec elseif hr > 10 and min > 10 and sec < 10 then script.Parent.Text = "Time Played: "..hr..":"..min..":0"..sec end end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
| |
|
|
| 02 Aug 2013 03:55 PM |
| Using game.Players.ChildAdded:connect... doesn't work in solo. You can try it on a test server though. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2013 03:55 PM |
| Did you do what I said " or 0" after the LoadNumber's |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:56 PM |
sec.Value = newPlayer:LoadNumber("Seconds") or 0 min.Value = newPlayer:LoadNumber("Minutes") or 0 hr.Value = newPlayer:LoadNumber("Hours") or 0 |
|
|
| Report Abuse |
|
|
Epic1230
|
  |
| Joined: 07 Dec 2011 |
| Total Posts: 289 |
|
|
| 02 Aug 2013 03:58 PM |
You can test it out here:
http://www.roblox.com/Hardcore-Parkour-WIP-place?id=108628878
Click stats and it just says "Time Played: 0:0:0" |
|
|
| Report Abuse |
|
|