Npc part breaking [NEEDS TO BE FIXED]

i have an npc which shoots a part (lazer) at the player, however when the part gets shot the npc just breaks (stops moving and infinitely jumping)

it is only the park breaking the npc, as if i dont set the parent it doesnt break but the lazer isnt there

code to shoot lazer:

local ShockClone = ShockPart:Clone()
	ShockClone.Anchored = true
	ShockClone.CanCollide = false
	ShockClone.CanQuery = false
	ShockClone.Massless = true
	ShockClone.Parent = biglenny
	for i, v in ipairs(ShockClone:GetChildren()) do
		if v:IsA("ParticleEmitter") or v:IsA("PointLight") then
			v.Enabled = true
		end
	end
	local startPosition = humanoidrootpart.Position
	local laserDistance = (startPosition - hitPosition).Magnitude
	local shockcframe = CFrame.lookAt(startPosition, hitPosition) * CFrame.new(0, 0, -laserDistance / 2)
	ShockClone.CFrame = humanoidrootpart.CFrame
	ShockClone.Transparency = 0
	local FireLazerT = tweenserv:Create(ShockClone, TweenInfo.new(lazerSpeed), {CFrame = CFrame.new(hitPosition)})
	FireLazerT:Play()
ShockClone.Touched:Connect(function(partTouched)
		if partTouched.Parent:FindFirstChild("Humanoid") and not partTouched.Parent:IsDescendantOf(biglenny) then
			print('hit player zap')
			partTouched.Parent:FindFirstChild("Humanoid").Health = 0
		end
	end)
FireLazerT.Completed:Wait()
ShockClone:Destroy()

I think the issue is with the “touched” event of the “ShockClone”. The NPC might be breaking cause the event is executing an action that is too uhh time-intensive. So you could try adding a delay before executing the action, so that it doesn’t happen too quickly.

What is the NPC’s code? Are you using PathfindingService to map paths for the NPC to move along? What is prompting you to recalculate the navigation mesh for the NPC? It sounds like the lazer’s part spawning is causing the NPC’s path to get blocked, and it’s getting stuck in a loop because it has no viable path.

removing the touched event doesnt change anything

i think this is the problem, but the part has CanQuery and all collisions off. sometimes it causes the npc to flip also

yeah

basically walk around until a target is found. when its found shoot a lazer at their last seen position

Can you try adding some print statements to your NPC’s code to find the hang-up? It may also be helpful if you send a video of what’s happening with the NPC.

its literally only the part. however there is a computation error


if u dont have any idea i can dm you the entire code

It may be helpful for me to see more code. You don’t necessarily need to send me everything, but if I could see some more of the NPC code I may be better able to deduce the issue.

Is the humanoid root part anchored? If it is, then that may be why it’s not moviing