Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make this NPC go from a to b, killing any humanoids in between it?

Asked by 3 years ago

Basically I need to to have this npc walk from the starting point, all the way to the end point, but if there are humanoids with the name lets say 'eat', the NPC will stop, do its damage attacks until its dead/gone, and then continue on to the ending point, and once reached the end point walk over to the secondary end point. https://gyazo.com/892e94dec2df22495500db1774d35f16 Not exactly sure how I would go about this, help is very much appreciated. Also, there will be multiple rows, not just the one, and I only want the NPC to attack the humanoids on the row that its walking on.

1 answer

Log in to vote
0
Answered by 3 years ago

First off, to move the actual npc, you could use Humanoid:MoveTo().

local Destination = "The Position of the NPC's destination" --Remove the quotes
Humanoid:MoveTo(Destination)

To kill anything that touches it while it's walking, you could use the .Touched event.

HumanoidRootPart.Touched:Connect(function(obj)
    if obj.Parent then
        if obj.Parent:FindFirstChild("Humanoid") then
            obj.Parent.Humanoid.Health = 0
        end
    end
end)

or you could use ray casting for something that doesn't touch the object. I'll provide help with ray casting if you need it. Just reply to this if you need help with it because ray casting requires a lot more coding.

0
Ok, that makes more sense now that I see it, but instead of just instantly killing the humanoid, how would I make it do separate attacks like 15 damage every 3 seconds Iroxxigar 24 — 3y
0
Use humanoid:TakeDamage() instead of setting the humanoid.Health to 0. The reason why is because it will set the health to 0 EVEN if there is a forcefield. Dovydas1118 1495 — 3y
Ad

Answer this question