Hi all I am making a Horror game and the anatagonist is not working properly
the problem is that the doll is going toward the destination part but for some reason is stopping in the middle
here is the move to scritp
wait(5)
local Doll = script.Parent
local Humanoid = Doll.Humanoid
while true do
Humanoid:MoveTo(workspace.Destination.Position)
Humanoid:MoveTo(workspace.Destination2.Position)
wait(0.5)
end
animation script
local animation = script.Animation
local humanoid = script.Parent.Humanoid
local animator = humanoid.Animator
local Running = animator:LoadAnimation(animation)
Running.Looped = true
humanoid.Running:Connect(function(speed)
if speed > 0 then
print("Player is running")
Running:Play()
else
print("Player has stopped")
Running:Stop()
end
end)
Use Humanoid.MoveToFinished to wait for the humanoid to finish walking to the given position.
wait(5)
local Doll = script.Parent
local Humanoid = Doll.Humanoid
while true do
Humanoid:MoveTo(workspace.Destination.Position)
Humanoid.MoveToFinished:Wait()
Humanoid:MoveTo(workspace.Destination2.Position)
Humanoid.MoveToFinished:Wait()
end
“:MoveTo()” finishes even if the destination isn’t reached after 8 seconds, consider using shorter paths and the aforementioned “.MoveToFinished” event.
The reach goal state of a humanoid will timeout after 8 seconds if it doesn’t reach its goal.