What should I choose


So I’ve basically already made the pathfinding thing, it works fine and all. But my question is if I am killing the NPC the best way I can? I am putting it in my while true do loop which yields to a runservice.Heartbeat:Wait(). The way I am detecting a player is by using workspace:GetPartsInBox.
I had three methods of detection:

  • Hitbox (Good Detection, Less optimal)
  • Touched Event (Optimal)
  • Checking distance is below a certain range and then killing the player (Good detection, less optimal. players annoyed they can’t move around the NPC)

I avoided the last one because I thought it would be very annoying if you are in a room and you wouldn’t be able to walk around the NPC or something. But it was an option I considered, but I was between the touched event and hitbox. I chose the hitbox for detection purposes, but was this the best idea? By the way the box is basically the size of the block rig.

local params = OverlapParams.new()
	params.FilterType = Enum.RaycastFilterType.Exclude
	params.FilterDescendantsInstances = {workspace.Rig}
	local hitbox = workspace:GetPartBoundsInBox(rigtorso.CFrame, workspace.Box.Size, params)
	for i, part in hitbox do
		if part.Parent:FindFirstChildOfClass("Humanoid") then
		part.Parent:FindFirstChildOfClass("Humanoid").Health = 0
		end
	end

Also if you guys could please let me know if you think this is a good NPC, I don’t think it lagged either in the video but I was thinking that it might do in the real game when there’s more players and not in a studio server. Or am I wrong? Did I make the right choice?

  • Hitbox (My choice)
  • Touched

0 voters

1 Like