|
| 02 Jan 2014 08:36 PM |
Ok, so I am making my own leaderboard (for 1-10 players. :))
Script:
local players = game.Players:GetChildren() local p1 = script.Parent.Player1 local p2 = script.Parent.Player2 local p3 = script.Parent.Player3 local p4 = script.Parent.Player4 local p5 = script.Parent.Player5 local p6 = script.Parent.Player6 local p7 = script.Parent.Player7 local p8 = script.Parent.Player8 local p9 = script.Parent.Player9 local p10 = script.Parent.Player10 local h = Instance.new("Hint") h.Parent = game.Workspace
while true do h.Text = "Updating Player's List" for i = 1, #players do p[i].Text = players[i].Name if p[i].Text == "" then p[i].Text = "Empty" end end wait(1) h:remove() wait(5) end
I get the error:
20:35:49.367 - Players.Player1.PlayerGui.PlayerList.List.Script:18: attempt to index global 'p' (a nil value) |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2014 08:37 PM |
you havent set a value for "p"
#nerdsunited |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2014 08:39 PM |
it's erroring at:
p[i]
in the for loop. |
|
|
| Report Abuse |
|
|
i0x3x
|
  |
| Joined: 27 Jan 2013 |
| Total Posts: 1308 |
|
|
| 02 Jan 2014 08:44 PM |
because p is nil
You set the variable to players, not me. |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2014 08:45 PM |
>.>
No. I set p(1-10) to a TextLabel in a gui...
I'm attempting to call to that in a for loop placing a player at a certain spot using
p[i]
.....
|
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 02 Jan 2014 09:34 PM |
| I don't think that's how you call elements in a table. |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2014 09:58 PM |
In one of my custom leaderboards, it is hidden except for when you are holding a hotkey. I used a simple for loop to build a gui for each player name. n the hotkey's release, the gui is removed completely.
~DiamondBladee~ |
|
|
| Report Abuse |
|
|
|
| 02 Jan 2014 11:59 PM |
@Diamond:
Will try that. You're basically say that everytime a player joins, a new gui is created? |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2014 12:02 AM |
Sort of, not really. In the leaderboard I'm talking about, it is hidden by default. Whenever a player does something to make it appear on-screen, it makes a gui for each player after using game.Players:GetChildren()
~DiamondBladee~ |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2014 12:03 AM |
| So, you're creating the gui everytime the button is pressed? But storing it somewhere within the game? |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2014 12:13 AM |
Nope, Im instancing an new one each time. I use :destroy() instead of visible = false.
~DiamondBladee~ |
|
|
| Report Abuse |
|
|