airsoft motion sensing gun

Hi i am trying to shoot my airsoft gun when some walks past a motion sensor....i hav all the materials and wired it up but it wont work......code is simple
Digitalread
If statement H
DigitalwriteH
Delay
DigitalwriteL

I have a transistor wired as such.....gate to pin 2 ....(digitalwrite in code)
Drain to negative terminal of airsoft motor
Source to negative of six volt battery for gun
And positive terminal of gun motor to positve on six volt battery.....

All the gun does is vibrate, burn me, and not shoot

I hate it when that happens

Any advice/help?

Any code/schematic?

Yep

Schematic == circuit diagram.
That isn't a circuit.

Well that is how its wired exactly, but here u go

You'll notice from your JPG that there is only one connection to the Arduino.
The minimum is often considered to be two (see my earlier comment about a "circuit")

Im using an irf510 transistor

Where would i connect another wire to?

Generally from the Arduino's ground to the power source's ground.

So your saying i should put the wire from arduino ground to six volt battery ground?

I tried something and took my multimeter set on 10x ohms and put the leads on drain and source of transistor and it is spiking up and down but its not connected to any power source or arduino

Wait its not spiking it is set at 6.4 all the time......steadily.......y ? I thought that a transistor only let current through when it had voltage going through the gate but there is not anything hooked up to gate right now

What were you expecting to see?
What does "multimeter set on 10x ohms" mean?

Edit: "6.4" what?

I dont know.....i was just messing around and when i was measuring resistance between the drain and source my multimeter displayed 64 ohms....sorry not 6.4

What do u think is wrong......could my transistor be bad? Did i wire the transistor wrong?

Should i try wiring it the other way around?

I suggest before going any further you do some research on the type of transistor you are using and work out what it does and how to use it correctly. This is not something you want to work out by trial and error since that is very likely to let the smoke out if you get it wrong.

This is not something you want to work out by trial and error since that is very likely to let the smoke out if you get it wrong.

Transistors are cheap, though, so it's not the end of the world if that happens. Do try to learn something from it, though.