I’ve tried many different approaches towards this but none of them ever work. Essentially, the NPC is shooting a projectile towards me, but instead of only hitting once, it hits up to 2-5 times and it’s genuinely confusing me, considering the original code was an exact replica of another NPC that I made (which also shoots projectiles) and those only hit once.
local bullet = Instance.new("Part", workspace:FindFirstChild("Disposable"))
bullet.CFrame = hrp.CFrame + hrp.CFrame.lookVector * 3; bullet.Size = Vector3.new(1.5, 1.5, 3)
bullet.Material = 288 --[[Number value for the neon enum]] bullet.Color = Color3.new(1,1,1); bullet.CanCollide = false
bullet.Anchored = false; bullet.CastShadow = false; bullet.Massless = true
local bv = Instance.new("BodyVelocity", bullet); bv.MaxForce = Vector3.new(1,1,1)*math.huge
bv.Velocity = bullet.CFrame.lookVector * 40
local m = Instance.new("SpecialMesh", bullet); m.MeshType = Enum.MeshType.Sphere
spawn(function() game.Debris:AddItem(bullet, 2.5)
local hitdb = {}
bullet.Touched:Connect(function(hit)
if ai:isPlr(hit.Parent) and ai:findHume(hit.Parent) then local found = false
for _,v in pairs(hitdb) do if hit.Parent == v then found = true; break end end
print(hitdb)
if not found then table.insert(hitdb, #hitdb + 1, hit.Parent)
ai:dmg(o_char, hit.Parent, 15)
end
elseif hit.CanCollide then bullet:Destroy() end
end)
end)
Any help will be appreciated ![]()