How to gate (jumper) external wires together, using MOSFAT but having problems

First, I just got my Arduino so super newb here....

I have 3 wires coming from another device (switch for sunroof). Wires are black, yellow, green. If you short black/yellow, roof goes forward, if you short black/green roof goes back. I have made two buttons on the Arduino with the goal of "joining" black to yellow, the other button, black to green.

I have 2 Mosfats. I have a digitalWrite pin13 going to gate on mosfat 1, black is on pin 2, and yellow is on pin three. Also pin 3 has ground on Arduino. This works, when I press button 1. The problem is on the second button. I have digitalwrite (pin12) on gate Mosfat 2, black on pin2 and green on pin3, (and the ground on Arduino) and THIS is the problem. Yellow and Green are now joined (via the ground on Arduino) and that turns out to cause a different function on the roof, while that is happening the black/yellow and black/green can not function separately.

I assuming I am doing this the wrong way, using Mosfat at all ... but not sure how to proceed? Is there a way to hookup black and yellow into pins on the Arduino and programmatically join them for a moment?

Before you start hooking things up, measure voltages on those three wires relative to eachother - I'll bet the black is ground - in that case, you want to have that on the source of the MOSFETs (which should be N-channel MOSFETs) (and tied to arduino ground), and the other two wires to the drain of the other two mosfets.

Also, you need to specify mosfet pins by the name of the pin (Gate, Source, Drain), not it's pin number, as the pin number to pin function mapping is not universal (check the datasheet to make sure you know which is which). And you need to specify if you're using an N or P channel MOSFET (if the common wire is at a lower voltage than the other two, you probably want an N-channel MOSFET, which is what I assumed above).

Thanks for the quick reply.

Actually I did try this (it was my original configuration) but that caused the roof to move immediately. I tried a lot of combinations. The switch doesn't go direct to the motor, it goes to another logic board that supplies power to the roof motor, so its not a simple rocker switch setup that does +/- to motor and -/+ .... hence why green and yellow also cause a function. That board is fried and now can just forward and back when you hold down the button (it used to be one touch opening and closing). My idea was to remake the one touch via the Arduino.

I will measure the voltage though (cant recall what it was). Mosets are RFP30N06LE model, I believe they are Gate, Drain, Source.

If you want to short/jumper to wires together, do you have to use the Mosfet ?

You typically need to use something to switch, unless the thing you're switching has compatible logic levels and can be interfaced directly, which doesn't look like the case here.

MOSFETs can be used as long as you're connecting one side to ground, or to a supply voltage.

A relay can always be used (and provide isolation), but they're bulky (and you need a mosfet to switch power to the coil, since they usually draw too much current to drive directly from an IO pin, and if it's running off battery with the relay energized for more that relatively brief periods of time, the battery life will be poor).

More complicated circuits can be made, of course, that address some of those problems - but much more would need to be known about what you're switching.