Crouch script problem!

I've made a very simple FPS game with all kinds of cool stuff, but the only problem is that my crouch script is having some kind of issues. If I crouch my character falls through floor! Is there a way to pervent it from doing that? Here is the script:

function Update ()

{

if (Input.GetKeyDown (“c”))

         {    transform.localScale.y = 0.25;}

if (Input.GetKeyUp (“c”))

 {    transform.localScale.y = 1.0;}

}

Your script works fine, it's just when you come out of the crouching state, the player expands downwards. This means that it would fall through the floor. I modified your script a little, and when attached to Unity's First Person Controller Prefab, it works fine.

Here is the script:

function Update ()
{

if (Input.GetKeyDown ("c"))
{ 
    transform.position.y -= 0.5;

    transform.localScale.y = 0.25;
}

if (Input.GetKeyUp ("c"))
{ 
    transform.position.y += 0.7;

    transform.localScale.y = 1.0;
}
}

Basically, all that I have added is two lines that adjust the players y position accordingly. If it does not work with your gameObject, try tinkering with some of the variables.