Change GameObject from different script

In one script that i will call main i have a gameobject

public class main
{
public GameObject selectedUnit;
}

how would i change what selectedUnit is from a script that was on a different object?

(also sorry if this is a dumb question im still new to unity and couldn’t find an answer on youtube so am asking you folks)