Hello
I’m trying to make an Npc react to attacks, tho any of my attempts worked
I’m trying to check if rng = 3 then check if “M1” is a child of the enemy
char is the player’s/Enemy model
Rng is the rng to determine if the npc will attack or defend:
if rng == 1 then
hit()
end
if rng >= 2 then
Defend()
end
What I have right now is:
if rng >=2 then
Defend()
end
What I have tried so far was:
if rng >=2 then
if char:FindFirstChild("M1") then
Defend()
end
end
And
If rng >=2 then
char.ChildAdded:Connect(function(child)
if child.Name = "M1" then
Defend()
end
end)
end
M1 object is created when the tool is fired and destroyed fairly quickly so how can I make the npc check if the enemy is attacking or not?