|
local Players = game:GetService("Players")
local PlayerTable = {}
Players.PlayerAdded:connect(function(Player)
for Index = 1,#PlayerTable do
if Player ~= nil then
PlayerTable[#PlayerTable + 1] = Player.Name
end
end
end) |
|
|
Does this count how many players there are on the server, or does it assign a number to their name
|
|
|
it counts how many players are in the server and then adds them to the table.
most people don't know this, but that blank table up there is actually;
PlayersTable = {nil, nil, nil, ...} |
|
|
SLOTHFUL! SLOTHFUL! SLOTHFUL! |
|
|
Ah, I had a feeling that it was a counter.
|
|
|
|
Oh my god dude, Subaru's neck cracked. I'm so sad rn, idk where he will respanw this time.
|
|
|
Felix saved Subaru af from that Witch Cult memer who blew himself up LOL
"My hands are the gentlest in the world"
"But, they're capable of doing some nasty things..." |
|
|
|
|
Not sure if your looking for a fix or not, but anyway...
Here is some new code:
-------------------------------
local PlayerTable = {}
local PlayerCount = 0
game.Players.PlayerAdded:connect(function(Player)
PlayerTable[Player.Name] = Player.Name
local Count = 0
for i, v in pairs(PlayerTable) do
Count = Count + 1
end
PlayerCount = Count
end)
game.Players.PlayerRemoving:connect(function(Player)
PlayerTable[Player.Name] = nil
local Count = 0
for i, v in pairs(PlayerTable) do
Count = Count + 1
end
PlayerCount = Count
end)
-------------------------------
By the way, if your just trying to get the player count.... just do
#game.Players:GetPlayers()
There really is no need to do all the code above when you can retrieve all players through game.Players:GetPlayers()
|
|
ValkeriJoin Date: 2012-05-12 Post Count: 753 |
felix mvp. healing magic so op |
|
|
|
sir why would i use in pairs?!
dis is an array not a dictionary >:( |
|
GraffybooJoin Date: 2015-04-23 Post Count: 5424 |
LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE LOVE
|
|
|
|
Yes, but in pairs() functions are inefficient in my opinion, I found the generic for loop to be more efficient!
:D |
|
|
*has no clue what is going on* |
|
|
@Ninja
The point of my code is to have the player added to the table, in the most efficient manner, once the player joins and connects to the game. So like, I am basically trying to figure out how to make my code as efficient as possible! ^_^ |
|
|
MeliorusJoin Date: 2008-12-24 Post Count: 8509 |
This weeb gonna try and learn how to script to make an anime remake
|
|
|
My new favorite word is DESU. |
|
|
|
I like Ram's voice and how she says Barusu. |
|
|