# Odd problem with a shootScript

**URL:** https://discussions.unity.com/t/odd-problem-with-a-shootscript/421753
**Category:** Scripting
**Tags:** Scripting
**Created:** [August 29, 2010, 5:28pm UTC](https://discussions.unity.com/t/odd-problem-with-a-shootscript/421753 "2010-08-29T17:28:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![anon\_50428097](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@anon\_50428097](https://discussions.unity.com/u/anon_50428097)
#### Post date: [August 29, 2010, 5:28pm UTC](https://discussions.unity.com/t/odd-problem-with-a-shootscript/421753/1 "2010-08-29T17:28:34Z")

</div>

I am making a car with a minigun turret on top, but i cant get my shoot script to work.  
I wrote my own script but when that failed i copied and modified the one from the script-reference.

the code is:

```auto
var Bullet : Transform;

function Update () {
	if (Input.GetButtonDown("Fire1")) {
	
	var clone : Rigidbody;
	clone = Instantiate(Bullet, transform.position, transform.rotation);
	clone.velocity = transform.TransformDirection (Vector3.forward * 10000);
}
}

```

but i keep getting a error saying: Cant cast from source type to destination type

checked everywhere but other that restarting unity i cant find any other suggested solutions and i have already restarted 100 times or so… plz help 😕

---

<div class="post-metadata">

### Author: ![SarperS](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/sarpers/32/372340_2.png) [@SarperS](https://discussions.unity.com/u/SarperS)
#### Post date: [August 29, 2010, 6:20pm UTC](https://discussions.unity.com/t/odd-problem-with-a-shootscript/421753/2 "2010-08-29T18:20:27Z")

</div>

You declare the Bullet variable as a Transform and then you are trying to cast a rigidbody to it.

change

```auto
var clone:Rigidbody

```

to

```auto
var clone:Transform

```

---

<div class="post-metadata">

### Author: ![anon\_50428097](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@anon\_50428097](https://discussions.unity.com/u/anon_50428097)
#### Post date: [August 29, 2010, 6:30pm UTC](https://discussions.unity.com/t/odd-problem-with-a-shootscript/421753/3 "2010-08-29T18:30:46Z")

</div>

Problem solved 🙂

thx for the help 😄

```auto
var Bullet : Transform;

function Update () {
	if (Input.GetButtonDown("Fire1")) {
		var clone : Transform;
		clone = Instantiate(Bullet, transform.position, transform.rotation);
		clone.rigidbody.velocity = transform.TransformDirection (Vector3.forward * 100);
	}
}

```
