You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
i want the humanoid to move but it doesnt move -
What is the issue? Include screenshots / videos if possible!
Humanoid is stuck at the same position, it never moves from the spot even when the script says its moving (i tried using the print debug method and the script works fine just the humanoid doesnt move) -
What solutions have you tried so far? Did you look for solutions on the Creator Hub?
I tried using :WaitForChild() for the variables
I also tried using humanoid.MoveToFinished() but it doesnt work too,
script works perfectly fine, its just the humanoid doesnt move i know this because i tested it with print() debug method and the script goes through the if statements and the walking track animation plays aswell
local module = require(script.Parent.ModuleScript)
local npc = script.Parent
npc:WaitForChild("HumanoidRootPart")
npc:WaitForChild("EnemyHumanoid")
local humanoid = script.Parent:WaitForChild("EnemyHumanoid")
local animator = humanoid:WaitForChild("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://127283851729330"
local track = animator:LoadAnimation(animation)
local debounce = false
game:GetService("RunService").Heartbeat:Connect(function()
module.GetClosestEnemy(npc)
if module.ClosestEnemy and module.ClosestRoot then
if module.ClosestDistance < 12.5 then
local backPos = npc.HumanoidRootPart.Position - npc.HumanoidRootPart.CFrame.LookVector * 2
npc.EnemyHumanoid:MoveTo(backPos)
if debounce == false then
debounce = true
track:Play()
end
humanoid.MoveToFinished:Connect(function(reached)
if reached then
debounce = false
track:Stop()
end
end)
return
end
if module.ClosestDistance < 17.5 then
npc.EnemyHumanoid:MoveTo(npc.HumanoidRootPart.Position)
return
end
npc.EnemyHumanoid:MoveTo(module.ClosestRoot.Position)
if debounce == false then
debounce = true
track:Play()
end
humanoid.MoveToFinished:Connect(function(reached)
if reached then
debounce = false
track:Stop()
end
end)
end
end)