im making a game and need attack script for an r6 npc i have everything like the movement finished but now i need some attack script please someone tell me how to make some.
✓ ANSWER ACCEPTED
Can someone give me some code for an npc to attack the nearest player?
1 answer
✓ Accepted answer
To find the nearest you can do a Magnitude check with the target
local Target = Workspace.Enemy.PrimaryPart --Example
local YourPosition = Script.Parent.PrimaryPart
local Distance = (Target.Position-YourPosition.Position).Magnitude
if Distance < 50 then --near the target by 50
Print("You are near the target")
end
3 comments
0
how do i make it attack though?
0
well you have to do it your self with a function or other methods
0
ok
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
For next time make sure to not ask for hand outs, this is helping site, not for free scripts.