I am making a zombie and have written in this script to make it follow me but it does not. I can push it around but no follow like I said. Here is the script to move:
1 | while true do |
2 | wait (. 1 ) |
3 | findNearestTorso() |
4 | if target~ = nil then |
5 | script.Parent.Humanoid:MoveTo(target.Torso.Position,target.Torso) |
6 | end |
7 | end |
What is wrong?
Assuming 'findNearestTorso return a target, that you want to follow.
1 | while true do |
2 | wait (. 1 ) |
3 | local target = findNearestTorso() |
4 | if target~ = nil then |
5 | script.Parent.Humanoid:MoveTo(target.Torso.Position,target.Torso) |
6 | end |
7 | end |
According to the code you provided, 'target' was nil so it technically never ran the line under it.
Please upvote if this work.