--Update list of players in admin panel

local selectPlrFrame = panel.Pages.MainButtonsFrame.ButtonsScroller.SelectPlayerFrame
local scroller = selectPlrFrame.PlayersScroller
local selectedFrame = selectPlrFrame.SelectedPlayerFrame
selectedFrame.Visible = false

function updatePlayers()
	for i, child in pairs(scroller:GetChildren()) do
		if child:IsA("TextButton") then
			child:Destroy()
		end
	end
	
	for i, plr in pairs(game.Players:GetPlayers()) do
		
		local btn = script.PlayerButton:Clone()
		
		local name = plr.Name
		btn.PlayerName.Text = name
		
		local image = game.Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
		btn.PlayerImage.Image = image
		
		btn.MouseButton1Click:Connect(function()
			
			selectedFrame.PlayerName.Text = name
			selectedFrame.DisplayName.Text = "@" .. plr.DisplayName
			selectedFrame.UserId.Text = plr.UserId
			selectedFrame.InGame.Text = "Currently in server 🟢"
			selectedFrame.PlayerImage.Image = image
			
			selectedFrame.Visible = true
		end)
		
		btn.Parent = scroller
	end
end
updatePlayers()
game.Players.PlayerAdded:Connect(updatePlayers)
game.Players.PlayerRemoving:Connect(updatePlayers)

