generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Leaderboards

Previous Thread :: Next Thread 
Epic1230 is not online. 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 is not online. 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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Aug 2013 03:14 PM
^^
It sometimes works
Report Abuse
Epic1230 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
02 Aug 2013 03:22 PM
Leaderboard still doesn't work.. Bump
Report Abuse
cntkillme is not online. 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 is not online. 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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Aug 2013 03:44 PM
for each value.
Report Abuse
Epic1230 is not online. 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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Aug 2013 03:46 PM
Before
Report Abuse
Epic1230 is not online. 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 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
02 Aug 2013 03:48 PM
Oops, forgot .Value
Report Abuse
cntkillme is not online. 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 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
02 Aug 2013 03:50 PM
Got it, now going to test it.
Report Abuse
Epic1230 is not online. 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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Aug 2013 03:51 PM
idk test it?
Report Abuse
Epic1230 is not online. Epic1230
Joined: 07 Dec 2011
Total Posts: 289
02 Aug 2013 03:54 PM
Still not working QQ..
Report Abuse
brandon58590 is not online. brandon58590
Joined: 08 Mar 2008
Total Posts: 996
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 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image