NPC shooting parts not working? No errors

I’m trying to make an NPC that shoots parts where it’s looking, the problem is when it creates the parts, they all just go to the side of the map and do nothing.
image

there are no errors, and I don’t understand why this is not working.

local DMG = 25
local CoolDown = 0.1
local Reload = 2
local ShootPart = script.Parent.Tool.Handle

function shoot()
	for count = 1,5 do
	local Bullet = Instance.new("Part", workspace)
	BulletClone = Bullet:Clone()
	BulletClone.CFrame = ShootPart.CFrame
	Bullet.Name = "SplatoonBullet"
	Bullet.Size = Vector3.new(4, 3.09, 8.63)
	Bullet.BrickColor = BrickColor.new("Neon orange")
	local Force = Instance.new("BodyThrust", Bullet)
	Force.Force = Vector3.new(10, 0, 0)
	end
end

while wait(5) do
	shoot()
end

I’m not entirely experienced when it comes to physics instances, such as a BodyThrust. However, have you considered playing around with the Force property so that it uses LookVector? It sounds to me that it is going the same way, regardless of direction.

Try:

Force.Force = ShootPart.CFrame.LookVector * 10

Secondly, if it falls to the ground, maybe counteract gravity by adding onto the Y value of force? Again, I am not 100% sure how the BodyThrust works, but these are just ideas and suggestions that could possibly solve the issue at hand.

Hope this helps. :slight_smile:

  • MattPrograms
1 Like

i know this isn’t part of the issue but when you create an instance with a parent argument, it would not respond quickly and be delayed like in this post here

anyways, in the problem why are you using vector to thrust the bullet? it would only go in the X axis. also you inserted the force into the bullet part, not the cloned bullets

1 Like

anyways, in the problem why are you using vector to thrust the bullet?

I don’t really know how to do this and I was experimenting around hoping to find a way to do this.

The way I suggested would direct it in the right way, rather than always in the same direction.

1 Like

anyways bodyforce is a type of velocity instance that applies force into instances it’s a descendant of, it doesn’t actually move them in the X axis, it forces them.

you should use this instead

local v = instance.new("bodyvelocity")
v.P = 500
v.Velocity = script.Parent.Tool.Parent.HumanoidRootPart.CFrame.lookVector * 40 --change this number to higher if you want it to be faster
v.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
v.Parent = bullet

it makes the bullet go to the direction of the npc’s humanoidrootpart it’s facing at, meaning if the rootpart is faced at 45 degrees, it’ll also go 45 degrees based on the lookvector, dont forget to rotate it based on the degrees, like bullet.CFrame = CFrame.new(bullet.Position, script.Parent.Tool.Parent.HumanoidRootPart.CFrame.lookVector).

1 Like

Ok, I changed it to

local DMG = 25
local CoolDown = 0.1
local Reload = 2
local ShootPart = script.Parent.Tool.Handle

function shoot()
	for count = 1,5 do
	local Bullet = Instance.new("Part", workspace)
	BulletClone = Bullet:Clone()
	BulletClone.CFrame = script.Parent.Tool.Handle.CFrame
	Bullet.Name = "SplatoonBullet"
	Bullet.Size = Vector3.new(4, 3.09, 8.63)
	Bullet.BrickColor = BrickColor.new("Neon orange")
	local v = Instance.new("BodyVelocity")
	v.P = 500
	v.Velocity = ShootPart.CFrame.lookVector * 40 --change this number to higher if you want it to be faster
	v.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	end
end

while wait(5) do
	shoot()
end

how would I be able to get the BulletClone to spawn at the Handle’s CFrame instead of far away on the ground?

BulletClone.CFrame = CFrame.new(script.Parent.Tool.Handle.Position)

atleast that’s how i make it so positions of instances go to another

1 Like

you forgot to put the velocity in the part

local v = Instance.new("BodyVelocity",Bullet)

and i’m prety sure you should fix this too

local Bullet = Instance.new("Part", workspace)-- this just becomes some random part in workspace
	BulletClone = Bullet:Clone()-- this is the bullet
	BulletClone.CFrame = script.Parent.Tool.Handle.CFrame
1 Like

wait so are all the clones going to spawn where the original one is? I can’t understand why they don’t spawn at the CFrame.

When your doing all this—— BulletClone.CFrame = script.Parent.Tool.Handle.CFrame
Bullet.Name = “SplatoonBullet”
Bullet.Size = Vector3.new(4, 3.09, 8.63)
Bullet.BrickColor = BrickColor.new(“Neon orange”) You forgot to put Clone after Bullet