how to attach scripts for the clone player at run time?

i got 2 scene,one for character, one for gamescene, how can i attach scripts for the clone player??
i try to use addcomponent, but it doesn’t work

GameObject prefab;

void Start()
{
    GameObject clone = Instantiate(prefab, Vector3.zero, Quaternion.identity);
    clone.AddComponent<YourScript>();
}