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

Custom Character NPC being unable to move?

Asked by 4 years ago
Edited 4 years ago

So basically I made an Enemy NPC with a custom character. When I try to use ":MoveTo()" the character stands still and looks at the character, sometimes shuffling a bit. I would love to have some insight into the problem. Thanks.

Main CodeBlock with moving:

        while wait() do
            if #game.Players:GetPlayers() > 0 and P.Humanoid.Health > 0 then
                for k,v in pairs(game.Players:GetPlayers()) do
                    local Chr = v.Character
                    if Chr ~= nil then
                        if (P.HumanoidRootPart.Position - Chr.HumanoidRootPart.Position).Magnitude < MaxDistance then
                            if (P.HumanoidRootPart.Position - Chr.HumanoidRootPart.Position).Magnitude < AttackDistance then
                                 -- Leaving this part out

                            else    
                                P.Humanoid:MoveTo(P.HumanoidRootPart.Position)
                                break

                            end 
                        end
                    end
                end
            end
0
where did you declare the maxdistance variable CrypxticDoge 135 — 4y
0
I declared it at the beginning, before the loop FadedDragoner 15 — 4y

Answer this question