Can somebody help me fix this script?

Im trying to get the following script to work but it doesn’t seem to work like it should. I want it to charge a shot and fire it with the charged force, in the moment it does not charge for some error in the script. Any help/tips is appreciated!
code:

public Transform firepoint;
public GameObject pumpkin3;
public float accelaration;
public float multiplicator;
private float shotdelay;
private float Nextfire = 0.0f;
float speed;
public float chargetime = 0.0f;
bool charging; 

void start()
{
    charging = false;
    multiplicator = 5f;
    shotdelay = 0.5f;
} 

void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        charging = true;
        speed = 0f;
        chargetime = 0f;
    }

    if (charging == true)
    {
        chargetime +=Time.deltaTime * multiplicator;
        speed = chargetime;
    }
    if (Input.GetMouseButtonUp(0))
    {
        GameObject Go = Instantiate(pumpkin3, firepoint.position, firepoint.rotation) as GameObject;
        Go.GetComponent<Rigidbody2D>().AddForce(new Vector2(accelaration * speed, accelaration));
        Nextfire = Time.time + shotdelay;
        charging = false;
    }
    if (Time.time > Nextfire)
    {
        chargetime = 0;
        speed = 0;
    }
}
}

if (Time.time > Nextfire)
{
chargetime = 0;
speed = 0;
}

This right here is probably your problem. I don’t know what you are trying to do with this block of code but what it is effectively doing is reseting your chargetime and speed every frame EVEN if you are currently charging.

I also don’t see anywhere that you are changing your acceleration variable so unless you are editing it in the inspector, it will be 0 and will mess up your addforce code. Hope this helps.

Well, your “start” method should have an upper case “S”, that would stop your initialization of some of your variables.

You should probably use if else statements since your fall through if statements are getting hit probably when you don’t want. An example is the first if that checks to see if the mouse button is down, if it is it sets charging to true, which is fine, this also makes the next if statement true and then in the next frame the same thing happens over and over resetting your variables like you just pressed the mouse button for the first time, particularly because your time and speed variables are reset to 0 every time a frame is rendered.

You may need to adjust your NextFire variable, but this should get you going:

void Update()
{
	if (Input.GetMouseButtonDown(0) && charging == false)
	{
		if (Time.time > Nextfire)
		{
			charging = true;
			speed = 0f;
			chargetime = 0f;
		}
	} 
	else if (Input.GetMouseButtonDown(0) && charging == true)
	{
		chargetime +=Time.deltaTime * multiplicator;
		speed = chargetime;
	}
	else if (Input.GetMouseButtonUp(0) && charging == true)
	{
		GameObject Go = Instantiate(pumpkin3, firepoint.position, firepoint.rotation) as GameObject;
		Go.GetComponent<Rigidbody2D>().AddForce(new Vector2(accelaration * speed, accelaration));
		Nextfire = Time.time + shotdelay;
		charging = false;
	}
}