Is there a function for this?

Is there a function for When a Scene is loaded , like if my scene loades, set this varible to one?

Yes.

function OnLevelWasLoaded()
{
    thisVariable = 1;
}

And I would really like it if you read through the scripting reference, because in the 22 minutes since you posted that question you could have easily found that just using the search bar.