Target always = nil!

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to make a follow script for my NPC

  2. What is the issue? I don’t know, I worked but after some test it no longer work.
    -The code is something like

target = nil
while wait() do
 if target then
  --code
 end
end

i placed 2 breakpoints at while and if target then. But it just stopped to break at while, if target, and while again over time. It doesn’t run the code inside if. The strangest thing is there was no error in the output

  1. What solutions have you tried so far? I look up, research a lot on internet, I checked the script
    this is all the script

and this is the explorer

image

please helppppp! I am stuck here about 4 days

1 Like

Does it ever show the print statement "Targeting " ..v.Name?
If not then it is most likely because the visionRange and abandonRange values are set too small. Try and increase these and see if the behaviour changes.

2 Likes

What does this here do? I think you can replace game.Players:GetChildren() with Players:GetPlayers

image

you can also replace local char = game.Workspace [v.Name] with Player.Character

2 Likes

Thanks, the problems were the vision Range and abandonRange. Thanks for your help, now i am really excited to continue my work!

I found a solution for the npc but your reply still help me for another thing. Thanks anyway…!

1 Like