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: Leaderboard Script question

Previous Thread :: Next Thread 
NewbControl114 is not online. NewbControl114
Joined: 09 May 2009
Total Posts: 10303
17 Aug 2012 01:10 PM
function onPlayerEntered(newPlayer)
--leaderstats (these will show up)

local stats = Instance.new("IntValue")
stats.Name = "leaderstats"

local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0
points.Parent = stats

-- otherstats (These won't show up)

local stats2 = Instance.new("IntValue")
stats2.Name = "otherstats"

local pirate = Instance.new("BoolValue")
pirate.Name = "Pirate_Noob"
pirate.Value = false
pirate.Parent = stats2

local richguy = Instance.new("BoolValue")
richguy.Name = "Rich_Noob"
richguy.Value = false
richguy.Parent = stats2

local oldguy = Instance.new("BoolValue")
oldguy.Name = "Old_Noob"
oldguy.Value = false
oldguy.Parent = stats2

local specialguy = Instance.new("BoolValue")
specialguy.Name = "Special_Noob"
specialguy.Value = false
specialguy.Parent = stats2

while true do
if newPlayer.Character ~= nil then break end
wait(5)
--apparently a VERY UGLY HACK
--(player enters before character?)
end

stats.Parent = newPlayer
stats2.Parent = newPlayer
end

game.Players.ChildAdded:connect(onPlayerAdded)

So, I'm writing a leaderboard script from scratch. There's 2 sets of values, one that does show up on the leaderboard (leaderstats) and one that doesn't (otherstats). I'm testing my game out and nothing is happening, and the output isn't reading any errors. Did I do something wrong?

Here's my Explorer:

Workspace
-Leaderstats
--leaderstats
---Points
--otherstats
---Pirate_Noob
---Special_Noob
---Old_Noob
---Rich_Noob

and that's it.
Report Abuse
NewbControl114 is not online. NewbControl114
Joined: 09 May 2009
Total Posts: 10303
17 Aug 2012 01:16 PM
Ok, thanks for the help :)
Report Abuse
orangegreenblue is not online. orangegreenblue
Joined: 04 Sep 2010
Total Posts: 10906
17 Aug 2012 01:26 PM
Does the output say anything?

-orangegreenblue, the Lua Noob
Report Abuse
zackeryjerrypowers is not online. zackeryjerrypowers
Joined: 01 Aug 2008
Total Posts: 1515
17 Aug 2012 01:46 PM
Where it says game.Players.ChildAdded:connect(onPlayerAdded)
You should've used onPlayerEntered, because that's your function's name.
Report Abuse
zackeryjerrypowers is not online. zackeryjerrypowers
Joined: 01 Aug 2008
Total Posts: 1515
17 Aug 2012 02:02 PM
Does that solve it?^^
Report Abuse
NewbControl114 is not online. NewbControl114
Joined: 09 May 2009
Total Posts: 10303
17 Aug 2012 02:06 PM
Thanks, simple mistype that I happened to overlook. Thanks.
Report Abuse
zackeryjerrypowers is not online. zackeryjerrypowers
Joined: 01 Aug 2008
Total Posts: 1515
17 Aug 2012 02:10 PM
No problem.
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
17 Aug 2012 02:21 PM
@zach, that doesn't work because onPlayerEntered isn't a valid method. change game.Players.ChildAdded to game.Players.PlayerAdded
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
17 Aug 2012 02:23 PM
Just use this script:

function onPlayerEntered(newPlayer)
--leaderstats (these will show up)

local stats = Instance.new("IntValue", newPlayer) --No parent
stats.Name = "leaderstats"

local points = Instance.new("IntValue", stats) -- No parent
points.Name = "Points"
points.Value = 0
points.Parent = stats

-- otherstats (These won't show up)

local stats2 = Instance.new("IntValue")
stats2.Name = "otherstats"

local pirate = Instance.new("BoolValue") --No parent
pirate.Name = "Pirate_Noob"
pirate.Value = false
pirate.Parent = stats2

local richguy = Instance.new("BoolValue") --No parent
richguy.Name = "Rich_Noob"
richguy.Value = false
richguy.Parent = stats2

local oldguy = Instance.new("BoolValue") --No parent
oldguy.Name = "Old_Noob"
oldguy.Value = false
oldguy.Parent = stats2

local specialguy = Instance.new("BoolValue") --No parent
specialguy.Name = "Special_Noob"
specialguy.Value = false
specialguy.Parent = stats2

while true do
if newPlayer.Character ~= nil then break end
wait(5)
--apparently a VERY UGLY HACK
--(player enters before character?)
end

stats.Parent = newPlayer
stats2.Parent = newPlayer
end

game.Players.PlayeAdded:connect(onPlayerAdded)
Report Abuse
NewbControl114 is not online. NewbControl114
Joined: 09 May 2009
Total Posts: 10303
17 Aug 2012 02:26 PM
My function is onPlayerEntered, not onPlayerAdded, so it wouldn't call correctly,

and why you put '--no parent' after every new value I don't know, I clearly define the parents a few lines down.

Also, 'PlayeAdded' isn't a valid child of game.Players.

I'm not sure if that was troll or not.
Report Abuse
zackeryjerrypowers is not online. zackeryjerrypowers
Joined: 01 Aug 2008
Total Posts: 1515
18 Aug 2012 11:42 AM
LOL NEWBCONTROL JUST OWNED YURR FAICE!
Report Abuse
zackeryjerrypowers is not online. zackeryjerrypowers
Joined: 01 Aug 2008
Total Posts: 1515
18 Aug 2012 11:44 AM
What's the difference between PlayerAdded and ChildAdded?
ChildAdded = When something is added to that parent.
PlayerAdded = When someone is added to the 'Players' parent.
Not much difference.
When player joins game:
'Player' recieves a new Child.
Thus you may use 'ChildAdded'.
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