local playersgathered
function getplayers()
local players = game.Players:GetChildren()
for i=1, #players do
playersgathered = players[i]
end
end
while true do
wait(5)
getplayers()
print(playersgathered.Name)
end
Playersgathered is just a variable that equals nil, what getplayers is doing is setting playersgathered to the first person, then to the second person, so it prints the second person each time. If you want it to print all their names you need to do:
local playersgathered = {}
function getplayers()
playersgathered = {}
local players = game.Players:GetChildren()
for _, v in pairs(players) do
table.insert(playersgathered, v)
end
end
while wait(5) do
getplayers()
for _, p in pairs(playersgathered) do
print(p.Name)
end
end
|