Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is this script not working?

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?

1 comment

0

Did you set a function of findNearestTorso?

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.