I need help with a little code entry pad.

how am i meant to compare the the state with oldstate before its even made

Because it contains the state of the switches the last time round the loop so you can comparison it with this time round the loop and see if you have anything changed.

What i have so far, am stuck though,

// Project Awesome. Code Entry With Four Buttons
int y = 0; // Set y
int x = 0; // Set x
int ledOne = 13; //Set Red LED
int ledTwo = 12; //Set Green LED
byte buttons[] = {2,3,4,5,6,7,8,9,10}; //Set buttons to array
byte pass[] = {2}; // Set password
byte attempt[1]; // Set attempts array
byte state[9]; // Make states array
byte oldstate[9]; // When button is hit, info added here
int time = 0;

void setup(){
  pinMode(ledOne, OUTPUT);
  pinMode(ledTwo, OUTPUT);
  for(x=0; x<9; x++){
    pinMode(buttons[x], INPUT);
  }
}


void loop(){
  for(x=0; x<9; x++){
    state[x] = digitalRead(buttons[x]); // Check states of each button
  }
  for(x=0; x<9; x++){
    if(state //...
  }
  for(x=0; x<1; x++){
    if(attempt[0] == pass[0]){
      Correct();
    }
  }
  if(attempt[0] != pass[0] && (millis() - time) > 5000){
    TimeOut();
  }
  for(x=0; x<9; x++){
    oldstate[x] = state[x];
  }
}

void Correct(){
  digitalWrite(ledOne, LOW);
  digitalWrite(ledTwo, HIGH);
}

void TimeOut(){
  digitalWrite(ledTwo, LOW);
  digitalWrite(ledOne, HIGH);
}

Basically when a button is hit i want the arduino to register it, save it in attempt[]

Then, you need to add a bit more code:
for(x=0; x<9; x++)
{
if(oldstate[ x ] != state[ x ])
{
if(state[ x ] == HIGH) // Was the switch just pressed?
{
attempt[ 0 ] = buttons[ x ]; //Set attempt (Just first index for now) to buttons pressed
time = millis();
}
}
}

ok, this is what ive got at the moment:

// Project Awesome. Code Entry With Four Buttons
int y = 0; // Set y
int x = 0; // Set x
int ledOne = 13; //Set Red LED
int ledTwo = 12; //Set Green LED
byte buttons[] = {2,3,4,5,6,7,8,9,10}; //Set buttons to array
byte pass[] = {2,3}; // Set password
byte attempt[2]; // Set attempts array
byte state[9]; // Make states array
byte oldstate[9]; // When button is hit, info added here
int time = 0;

void setup(){
  pinMode(ledOne, OUTPUT);
  pinMode(ledTwo, OUTPUT);
  for(x=0; x<9; x++){
    pinMode(buttons[x], INPUT);
  }
  digitalWrite(ledOne, HIGH);
    for(x=0; x<9; x++){
    state[x] = digitalRead(buttons[x]); // Check states of each button
  }
  for(x=0; x<9; x++){
    oldstate[x] = state[x];//Send all data to different array
  }
}


void loop(){
  for(x=0; x<9; x++){
    state[x] = digitalRead(buttons[x]); // Check states of each button
  }
  for(x=0; x<9; x++){
    if(oldstate[x] != state[x]){ //If these new states are different then the old ones
      if(state[x] == HIGH)
      {
        attempt[x] = buttons[x]; //Set attempt (Just first index for now) to buttons pressed
        time = millis();
      }
    }
  }
  for(x=0; x<2; x++){
    if(attempt[0] == pass[0]){
      Correct();
    }
  }
  if ((millis() - time) > 5000){
    for(x=0;x<1;x++){
      attempt[x] = 0;
    }
  }
  if(attempt[0] != pass[0]){
    TimeOut();
  }
  for(x=0;x<9;x++){
    oldstate[x] = state[x];
  }
}

void Correct(){
  digitalWrite(ledOne, LOW);
  digitalWrite(ledTwo, HIGH);
}

void TimeOut(){
  digitalWrite(ledTwo, LOW);
  digitalWrite(ledOne, HIGH);
}
  for(x=0; x<9; x++){
    if(oldstate[x] != state[x]){ //If these new states are different then the old ones
      if(state[x] == HIGH)
      {
        attempt[x] = buttons[x]; //Set attempt (Just first index for now) to buttons pressed

attempt does not have 9 elements...

  for(x=0; x<2; x++){
    if(attempt[0] == pass[0]){
      Correct();
    }
  }

You are checking that the first element in each array matches twice. Not exactly what you want to do, is it?

  if ((millis() - time) > 5000){
    for(x=0;x<1;x++){
      attempt[x] = 0;
    }
  }

How many times is that loop going to execute?

the first bit should be two i see, the third on is just because attempt has one element, if it had 2 id just have to change the x<, and the second bit was wrong :L

actually, wait a second, if the first one wasnt set to 9 it wouldnt go through each state to see if it was pressed.

but if i set it a different variable, which increases each time a button is pressed, i think i know what to do

ok this is what i have, blank the for statements that say x<1, pretend theyre just the if statements within

// Project Awesome. Code Entry With Four Buttons
int y = 0; // Set y
int x = 0; // Set x
int ledOne = 13; //Set Red LED
int ledTwo = 12; //Set Green LED
byte buttons[] = {2,3,4,5,6,7,8,9,10}; //Set buttons to array
byte pass[] = {2,3}; // Set password
byte attempt[2]; // Set attempts array
byte state[9]; // Make states array
byte oldstate[9]; // When button is hit, info added here
int time = 0;

void setup(){
  pinMode(ledOne, OUTPUT);
  pinMode(ledTwo, OUTPUT);
  for(x=0; x<9; x++){
    pinMode(buttons[x], INPUT);
  }
  digitalWrite(ledOne, HIGH);
    for(x=0; x<9; x++){
    state[x] = digitalRead(buttons[x]); // Check states of each button
  }
  for(x=0; x<9; x++){
    oldstate[x] = state[x];//Send all data to different array
  }
}


void loop(){
  for(x=0; x<9; x++){
    state[x] = digitalRead(buttons[x]); // Check states of each button
  }
  for(x=0; x<9; x++){
    if(oldstate[x] != state[x]){ //If these new states are different then the old ones
      if(state[x] == HIGH)
      {
        attempt[y] = buttons[x]; //Set attempt (Just first index for now) to buttons pressed
        y++;
        time = millis();
      }
    }
  }
  for(x=0; x<1; x++){
    if(attempt[0] == pass[0]){
      Correct();
    }
  }
  if ((millis() - time) > 10000){
    for(x=0;x<1;x++){
      attempt[x] = 0;
      y=0;
    }
  }
  if(attempt[0] != pass[0]){
    TimeOut();
  }
  for(x=0;x<9;x++){
    oldstate[x] = state[x];
  }
}

void Correct(){
  digitalWrite(ledOne, LOW);
  digitalWrite(ledTwo, HIGH);
}

void TimeOut(){
  digitalWrite(ledTwo, LOW);
  digitalWrite(ledOne, HIGH);
}

Are your buttons labled 2 to 10 ? Because that is what you are compairing attempt to.
Y can get greater than 2 so you over run the array, it needs fixing. By restricting what Y can be.

its pin 2 - 10, so yeah the buttons are numbered 2-10 as long that is remembered in the coding it wont effect the way the hardware looks and works.
how do i restrict Y, by adding a different variable to 1 and then when Y = 2, set the different variable to 0?

how do i restrict Y

You use an if statement where by if y is greater than the maximum you want you have a statement to make it the maximum.

OK, thats more or less fine, i still have an issue that if i leave the thing for too long (literally a minute) and the green light flashes on goes out and the red light doesnt change at all

I think this is because you are overrunning your arrays. Make them all the size they will be eventually even if you don't put anything in them.

OK, i will do,

also i added:

  if(y > 3){
    for(x=0;x<1;x++){
      attempt[x] = 0;
    }
    y=0;
  }

so if you go over 2 presses, it goes back to start.

  if(y > 3){
    for(x=0;x<1;x++){
      attempt[x] = 0;
    }
    y=0;
  }

So, how many times does that loop execute? Which elements of the array are you resetting?

Do your self a favor. Add some #define statements to the top of your code to define some names:

#define BTNCNT 9
#define ATTCNT 2

Then, use these names when you declare arrays:

byte buttons[BTNCNT] = {2,3,4,5,6,7,8,9,10}; //Set buttons to array
byte pass[ATTCNT] = {2,3}; // Set password
byte attempt[ATTCNT]; // Set attempts array
byte state[BTNCNT]; // Make states array
byte oldstate[BTNCNT]; // When button is hit, info added here

This will ensure that all arrays are properly sized.

Then, use these names in loops, and other places, too:

  for(x=0; x<BTNCNT; x++)
  {
    pinMode(buttons[x], INPUT);
  }
  for(x=0; x<ATTCNT; x++)
  {
    if(attempt[x] == pass[x])  // <== Fixed these, too
    {
      Correct();
    }
  }

Also, think about what are reasonable values for the limit conditions:

  if(y > 3)
{

Since this test will be false until y is 4, it means that y=0, y=1, y=2, and y=3 are good values, and that attempt[3] is a good place to write to. As currently structured, it is not. If you tested for y>=ATTCNT, the test would limit the index to the maximum that is valid for the array.

Changing the value associated with ATTCNT from 2 to 4 to 12 then requires no other code changes to create and accommodate larger arrays.

Thanks for that, im still new to arduino so im not too great at the coding yet, as you may have noticed.

ok, ive done what you said, but when i verify the code i keep on getting the error: expected ']' before ';' token.

#define BTNCNT 9;
#define ATTCNT 2;
int a = 0; //set a
int y = 0; // Set y
int x = 0; // Set x
int ledOne = 13; //Set Red LED
int ledTwo = 12; //Set Green LED
byte buttons[BTNCNT] = {2,3,4,5,6,7,8,9,10}; //Set buttons to array
byte pass[ATTCNT] = {2,3}; // Set password
byte attempt[ATTCNT]; // Set attempts array
byte state[ATTCNT]; // Make states array
byte oldstate[ATTCNT]; // When button is hit, info added here
int time = 0;

void setup(){
  pinMode(ledOne, OUTPUT);
  pinMode(ledTwo, OUTPUT);
  for(x=0; x<BTNCNT; x++){
    pinMode(buttons[x], INPUT);
  }
  digitalWrite(ledOne, HIGH);
}


void loop(){
  for(x=0; x<BTCNT; x++){
    state[x] = digitalRead(buttons[x]); // Check states of each button
  }
  if(attempt[0] != pass[0]){
    TimeOut();
  }
  for(x=0; x<BTNCNT; x++){
    if(oldstate[x] != state[x]){ //If these new states are different then the old ones
      if(state[x] == HIGH)
      {
        attempt[y] = buttons[x]; //Set attempt (Just first index for now) to buttons pressed
        y++;
        time = millis();
      }
    }
  }
  for(x=0; x<ATTCNT; x++){
    if(attempt[0] == pass[0]){
      Correct();
    }
  }
  if ((millis() - time) > 10000){
    for(x=0;x<ATTCNT;x++){
      attempt[x] = 0;
      y=0;
    }
  }
  if(y > 3){
    for(x=0;x<ATTCNT;x++){
      attempt[x] = 0;
    }
    y=0;
  }
  for(x=0;x<BTNCNT;x++){
    oldstate[x] = state[x];
  }
}

void Correct(){
  digitalWrite(ledOne, LOW);
  digitalWrite(ledTwo, HIGH);
}

void TimeOut(){
  digitalWrite(ledTwo, LOW);
  digitalWrite(ledOne, HIGH);
}

can you try and verify, because i cant see whats wrong

byte buttons[BTNCNT] = {2,3,4,5,6,7,8,9,10} ; //Set buttons to array

If you specify the size of the array then you can't initialise it like this, you have to use:-

byte buttons[] = {2,3,4,5,6,7,8,9,10} ; //Set buttons to array

ok, i did what you said in the reply before so i assumed it worked.