PlusJon
|
  |
| Joined: 27 Sep 2012 |
| Total Posts: 1522 |
|
|
| 12 Nov 2012 04:55 PM |
plrs = { }
game.Players.PlayerAdded:connect(function(p) add = true for _,v in pairs(plrs) do if v.Name == p.Name then add = false break end end if add then table.insert(plrs, p.Name) workspace.uniquePlayers.Value = workspace.uniquePlayers.Value +1 end end)
It doesn't catch duplicate names...It just sort of skips the whole check.
I've tested this in both online servers, and offline servers. |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2012 04:56 PM |
| Is there something in the output? |
|
|
| Report Abuse |
|
|
PlusJon
|
  |
| Joined: 27 Sep 2012 |
| Total Posts: 1522 |
|
| |
|
PlusJon
|
  |
| Joined: 27 Sep 2012 |
| Total Posts: 1522 |
|
|
| 12 Nov 2012 04:59 PM |
| The problem is it works, but doesn't work correctly. Which it should. |
|
|
| Report Abuse |
|
|
PlusJon
|
  |
| Joined: 27 Sep 2012 |
| Total Posts: 1522 |
|
|
| 12 Nov 2012 05:03 PM |
| Nevermind. I forgot the '#' in the for do part. |
|
|
| Report Abuse |
|
|
PlusJon
|
  |
| Joined: 27 Sep 2012 |
| Total Posts: 1522 |
|
|
| 12 Nov 2012 05:04 PM |
NVM again. T_T
I'm tired. :L |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2012 05:04 PM |
Try if add == false then
It probably won't work, but in there I can't see anywhere that you insert the name into the table... |
|
|
| Report Abuse |
|
|
PlusJon
|
  |
| Joined: 27 Sep 2012 |
| Total Posts: 1522 |
|
|
| 12 Nov 2012 05:09 PM |
plrs = { }
game.Players.PlayerAdded:connect(function(p) add = true -- Make it new by default for _,v in pairs(plrs) do -- Start the scan if v.Name == p.Name then -- does the name exist in the table yet add = false -- we found it does so set it to false so it doesn't add it break -- stop checking end end if add then -- if add is STILL true, which SHOULD be made false when duplicate name is found table.insert(plrs, p.Name) -- add the name to the table workspace.uniquePlayers.Value = workspace.uniquePlayers.Value +1 -- increase the value end end) |
|
|
| Report Abuse |
|
|
PlusJon
|
  |
| Joined: 27 Sep 2012 |
| Total Posts: 1522 |
|
|
| 12 Nov 2012 05:12 PM |
"if v.Name == p.Name then"
*facedesk*
I failed. Lol. |
|
|
| Report Abuse |
|
|
|
| 12 Nov 2012 05:12 PM |
plrs = { }
game.Players.PlayerAdded:connect(function(p) add = true for _,v in pairs(plrs) do if v.Name == p.Name then add = false return --break breaks the loop end end if add then table.insert(plrs, p.Name) workspace.uniquePlayers.Value = workspace.uniquePlayers.Value + 1 end end)
~ thedeathmaster01 ~ |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Nov 2012 05:13 PM |
| Maybe add needs to become false again at the end now that the name is found? |
|
|
| Report Abuse |
|
|
PlusJon
|
  |
| Joined: 27 Sep 2012 |
| Total Posts: 1522 |
|
|
| 12 Nov 2012 05:16 PM |
@Thedeathmaster
Why wouldn't I break the loop if the name was found? Why keep looking?
Return is useless in this case.
@TheAwesomeDude
No, that's not a problem.
@All I fixed it. |
|
|
| Report Abuse |
|
|