# How to solve system of equations in Do loop and replace the answer?

I want to solve equations and substitute one of the variable with the answer.
For example, here I have two variables (x, y) and two constants (a, b) ranging from 1~10, use FindRoot to solve them. I want to output only the x solution and replace it with the variable "x".

Do[sol = FindRoot[{a x + b y == 0, a x - b y == 4}, {x, 0}, {y, 0}], x = x /. sol[[1]], {a, 1, 10}, {b, 1, 10}]


But there must be something wrong. How can I solve it?
Thanks~

I want to output only the x solution and replace it with the variable "x".

I am not sure what you mean by this. Do you want only the x solutions in list as numbers and assign this list to x? or something else?

Clear["Global*"]
root[a_Integer, b_Integer, x_Symbol, y_Symbol] :=
FindRoot[{a x + b y == 0, a x - b y == 4}, {x, 0}, {y, 0}]

data = Flatten[Table[root[a, b, x, y], {a, 1, 10}, {b, 1, 10}], 1];
data /. {x -> any1_, y -> any2_} :> x -> any1


The above gives

If you just want list of the x values assigned to x variable (btw, I think it is better to assign this to new variable name and not x. Something like xSol. So this below becomes xSol = x /. data but if you want to use x as variable then

x = x /. data


and now x variable is

And if you want only unique values in x you can do

x = Union[x]
`

Other variations are possible.