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 8 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:

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

What is wrong?

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

1 answer

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

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

while true do
    wait (.1)
    local target = findNearestTorso()
    if target~= nil then
        script.Parent.Humanoid:MoveTo(target.Torso.Position,target.Torso) 
    end
end

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