How could I make this script see if the players is game or not?

I am trying to make a ban system similar to Roblox Bedwars, but I have no idea how to check if the player is in the server or not. The if else loop doesnt work, I just get an error that says,

Player is not a valid member of Players "Players"

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if string.find(msg, "/ban") then
			local args = string.split(msg, " ")
			if game.Players[args[2]] then
				game.Players[args[2]].BanData.Banned.Value = true
			else
				print('User is offline or doesnt exist')

			end			
		end
	end)
end)

Is args[2] the name of the target player to ban?

Use :FindFirstChild instead of game.Players[PlayerName]

if game.Players:FindFirstChild(args[2]) then
	game.Players:FindFirstChild(args[2]).BanData.Banned.Value = true