# Booleans in button inputs - help

So i have this set up so the first time i press spacebar (jump) it’s supposed to roll the dice

And then the second time it’s pressed it resets the level so you can roll it again

but it’s not working… i THINK it has something to do with the booleans in the if statements for button input… but i’ve been screwing with it for hours

``````#pragma strict

//create variables for the force inputs
var intYForce : int;
var intXForce : int;
var intZForce : int;
//create variable for angstyness
public var chuckingStrength : int;
//define d20fixed as a rigid body so we can do physics stuff
var d20fixed : Rigidbody;
//declare jumpBlocked cariable
private var jumpBlocked = false;

function Start(){

//set initial value of chuckingstrength
chuckingStrength=10;

}
function Update () {

//throw the dice if jumpBlocked is false
if(jumpBlocked==false && Input.GetButtonDown("Jump")){

//set randoms for force inputs
intXForce=Random.Range(-10,10);
intYForce=Random.Range(1,10);
intZForce=Random.Range(-10,10);

//make sure they're not zero
while(intXForce==0){
intXForce=Random.Range(-10,10);
}
while(intZForce==0){
intZForce=Random.Range(-10,10);
}

d20fixed.useGravity=true;

//set jumpBlocked to true so it will reset the level next time spacebar is pressed
jumpBlocked = true;

}

//reload the level if jump is pressed and it is set to blocked
if(jumpBlocked==true && Input.GetButtonDown("Jump")){

//set jumpBlocked back to false so you can roll again after reset
jumpBlocked = false;

}
//make it so when you press the up button angst goes up
if(Input.GetButtonDown("up")){

chuckingStrength = chuckingStrength + 1;
if(chuckingStrength==21)  {
chuckingStrength = 20;
}
}

//make it so when you press the down button angst goes down
if(Input.GetButtonDown("down")){

chuckingStrength = chuckingStrength - 1;
if(chuckingStrength==2)  {
chuckingStrength = 3;
}
}

if(Input.GetButtonUp ("exit")){
Application.Quit();
}

}

//function to wait 3 seconds and reload the level
//block input
//	jumpBlocked = true;
//wait chuckingStrength/3 seconds
//	yield WaitForSeconds ((chuckingStrength/5)+1);
//unblock input
//	jumpBlocked = false;
//}
``````

Thank you in advance! I’m pretty sure it’s something simple but i’m a noob and can’t see it

to be more specific… when i press spacebar (jump) it just resets the level… it never rolls the die

Insert this into your code, and change RollDice() to whatever your dice roll function’s name is

``````function Update()
{
if(Input.GetButtonDown("Jump"))
{
if(jumpBlocked== false)
{
RollDice();
jumpBlocked= true;
}
else
{
jumpBlocked= false;
}
}
}
``````

Also, if you reload the level, how could any dice be rolled? After all, everything is reset, no?