I’m making a momentum variable & I want to set it to 0 initially, but I don’t know how to create the variable without the script setting the variable back to 0 every time it loops the script
function Update () {
var momenti = 0;
if(Input.GetKeyDown(“left”)){
momenti = momenti + .3;
transform.position.x = transform.position.x + momenti;
} else if(Input.GetKeyDown(“right”)){
momenti = momenti - .3;
transform.position.x= transform.position.x - momenti;
}}