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

How do i make an NPC not attack a specific person?

Asked by
G0ZZEN 17
5 years ago
Edited 5 years ago

So I made an NPC that attacks other people how can I make that it doesn't attack the owner or someone specific? I currently have this as my chase script:

01wait()
02zombieParent = false
03 
04while zombieParent == false do
05 
06    wait()
07    if script.Parent.Name == "Knight" then
08        zombieParent = true
09    end
10 
11end
12 
13local larm = script.Parent:FindFirstChild("Left Arm")
14local rarm = script.Parent:FindFirstChild("Right Arm")
15local waitTimer = 0
View all 85 lines...

1 answer

Log in to vote
0
Answered by 5 years ago

This is a relatively simple solution, as where you can use conditional statements (also known as if statements) to determine things.

Here's a sample:

1if 1 + 1 == 2 then
2    print("Math")
3else
4    print("Math Broke")
5end

So here, it will always print math since 1 + 1 is equivalent to 2. The concept is similar to imply into your script:

1if Target.Name ~= "person" then
2    -- do not attack
3else
4    -- attack
5end

So where you get your target (assuming you know the script also assuming you made it), check the player or target via name or player user id if it is a player and then you will be done!

Hope this helped, best of luck!

Ad

Answer this question