Why won't this gun script work?
I have this script:
01 | function FireBullet(pos) |
02 | script.Parent.Handle.LaserShot:Play() |
03 | local p = Instance.new( "Part" ) |
04 | p.Parent = game.Workspace |
06 | p.Size = Vector 3. new( 0.4 , 0.4 , 1 ) |
08 | p.CFrame = CFrame.new(script.Parent.Handle.Position) |
10 | p.BottomSurface = "Smooth" |
11 | p.Color = Color 3. new( 0 , 255 , 0 ) |
14 | local l = Instance.new( "PointLight" ) |
16 | l.Color = Color 3. new( 0 , 255 , 0 ) |
19 | local v = Instance.new( "BodyVelocity" ) |
21 | v.velocity = pos-script.Parent.Handle.Position |
22 | local g = Instance.new( "BodyGyro" ) |
24 | local po = script.Parent.Handle.Position |
25 | g.cframe = CFrame.new(Vector 3. new(po.x,po.y,po.z),(CFrame.new(pos).p-Vector 3. new(po.x,po.y,po.z)).unit* 300 ) |
28 | p.Touched:connect( function (part) |
29 | if part.Parent:FindFirstChild( "Humanoid" ) then |
30 | if not part.Parent.Name = = script.Parent.Parent.Name then |
31 | script.Parent.Handle.LaserHit:Play() |
32 | part.Parent.Humanoid:TakeDamage( 25 ) |
38 | if p.Parent = = game.Workspace then |
43 | script.Parent.Equipped:connect( function (mouse) |
44 | mouse.Button 1 Down:connect( function () |
45 | FireBullet(mouse.Hit.p) |
I want this script to make a bullet appear at the handle of the tool, then move to where the player clicked to fire the bullet.
It should work but the only problem is that the bullet won't move after I have clicked, is there something wrong with the script? The output won't give me anything.