Creating a prefab and editing variables in its script

I am creating a prefab in a script and the prefab has a script attached to it. I want to set variables in the prefabs script but am struggling to do so. The variables I want to set are public variables.

when you instantiate your prefab catch the reference:

var instanceofmyprefab = instantiane(what,where,how);
var scriptiwanttoedit = instanceofmyprefab.GetComponent(ScriptClass);
scriptiwanttoedit.publicvariable = whatever;