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

Why is this script not working?

Asked by 9 years ago

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:

1while true do
2    wait (.1)
3    findNearestTorso()
4    if target~= nil then
5        script.Parent.Humanoid:MoveTo(target.Torso.Position,target.Torso)
6    end
7end

What is wrong?

0
Did you set a function of findNearestTorso? Shawnyg 4330 — 9y

1 answer

Log in to vote
0
Answered by
Kurieita 125
9 years ago

Assuming 'findNearestTorso return a target, that you want to follow.

1while 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
7end

According to the code you provided, 'target' was nil so it technically never ran the line under it.

Please upvote if this work.

Ad

Answer this question