Hi, I'm trying to create a part with a mesh of a snake. I want this snake to then follow any users within the magnitude of 40 studs and to continue doing so until they've left the magnitude. - For example. They died.
However, at this point in time, the snake won't move and I can't seem to work out why...
while wait(.1) do
for i,v in pairs(workspace:GetChildren()) do
if v:IsA("Model") then
x = v:FindFirstChild("Humanoid")
if x then
c = v:FindFirstChild("dontcome") --This is inside certain players to prevent snakes chasing them...
if c then
else
z = x.Parent:FindFirstChild("Head")
if z then
if x.Health < 1 then
else
if (script.Parent.Head.Position - z.Position).Magnitude <= 40 then
script.Parent.Humanoid:MoveTo(z.Position)
else
wait(0.01)
end end
end
end end
end
end
end
Everything inside the "Snake":
https://gyazo.com/5de683e395307fd7f43f8064aa6d86b2
There are no errors in the output either.
Thank you.

2 comments
Also, I don't have the item inside my character called "dontcome". So thats not affecting it..
I think I got it now