|
| 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 |
|
|
|
| 17 Aug 2012 01:16 PM |
| Ok, thanks for the help :) |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2012 01:26 PM |
Does the output say anything?
-orangegreenblue, the Lua Noob |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 17 Aug 2012 02:06 PM |
| Thanks, simple mistype that I happened to overlook. Thanks. |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 18 Aug 2012 11:42 AM |
| LOL NEWBCONTROL JUST OWNED YURR FAICE! |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|