I ran into this problem as well. For me, it was due to having history for defected servers still around. Essentially, there was job run history for servers where there was no longer a Server_id in the msdb.dbo.systargetservers table. Something in the scripting process saw those NULL Server_ids in the history and threw the error.
I found the solution on the following URL:
https://sqlsanctum.wordpress.com/2015/02/12/multi-server-job-scripting-failure/
You can quickly find if you have the same scenario with the query below (from the same URL):
SELECT
[JobName] = j.Name
,[JobServerId] = js.Server_id
,[TargetServerId] = ts.Server_id
FROM msdb.dbo.sysjobservers js
INNER JOIN msdb.dbo.sysjobs j ON j.job_id = js.job_id
LEFT JOIN msdb.dbo.systargetservers ts ON ts.server_id = js.server_id
WHERE j.category_id = 2 AND ts.server_id IS NULL
You can delete the history by running the command below (also from the same URL) which should allow you to script the job:
DELETE FROM js
FROM msdb.dbo.sysjobservers js
INNER JOIN msdb.dbo.sysjobs j ON j.job_id = js.job_id
LEFT JOIN msdb.dbo.systargetservers ts ON ts.server_id = js.server_id
WHERE j.name = 'JobName' AND ts.server_id IS NULL