Raycast pink material

Hi all,
i’m a beginner with Unity and I have a problem with RayCast.
My objective is to make a chess board, and to change the color of the square I click on, the selection is correct (the correct square change color), but it become pink. Here is my full code (the raycast is at line 31) :

using UnityEngine;
using System.Collections;

public class Modele : MonoBehaviour {
	public Material mat;
	// Use this for initialization
	void Start () {
		GameObject caseC, caseF;
		caseC = GameObject.Find("CaseC");
		caseF = GameObject.Find("CaseF");
		GameObject tmp = null;
		for(int i=0 ; i<8 ; i++) {
			for(int j=0 ; j<8 ; j++) {
				if(i%2 == j%2)
					tmp = (GameObject)Instantiate(caseC);
					tmp = (GameObject)Instantiate(caseF);
				tmp.transform.position = new Vector3(i,0,j);
		select = null;
	// Update is called once per frame
	void Update () {
		if (Input.GetMouseButtonDown(0)){ // if left button pressed...
			Ray ray = camera.ScreenPointToRay(Input.mousePosition);
			RaycastHit hit;
			if (Physics.Raycast(ray, out hit)){
				hit.collider.gameObject.renderer.material = mat;


As you can see in the screen, my public variable is set. I also tried to do it with the texture directly (with a Texture variable and with the material.mainTexture attribute), but it make the area white.

An other small question would be : what is the better way to create 64 squares, I don’t think my method is really good…

Sorry for my English, It’s not my native language, and thank you for your time.

select an object that the script is attached to, then in the inspector scroll down to the script and see THERE if the material is assigned.
your screenshot does not tell weather the mat is assigned or not