humanoid:MoveTo() Not working

I was wondering if anyone could tell me why the humanoid is not moving in this script. It runs the code, but the humanoid doesn’t move.

local targetting = false
local target = nil
local targetdist = nil
local hum = game.Workspace.Pain.Humanoid
local head = game.Workspace.Pain.Head

function targettingDisable()
	wait(15)
	targetting = false
	target = nil
end

function engage()
	repeat 
		print("Engaging")
		local randomclosepos = Vector3.new(head.Position.X + math.random(1,45), 0, head.Position.Z + math.random(1,45))
		print(hum.Parent.Name)
		hum:MoveTo(randomclosepos)
		print(randomclosepos)
		wait(1)
	until targetting == false
end

while wait(1) do
	local npchead = script.Parent:WaitForChild("Head")
	
	if targetting == false then
		for _, player in pairs(game.Players:GetChildren()) do
			local charhead = player.Character:WaitForChild("Head")
			
			local mag = (npchead.Position - charhead.Position).Magnitude
			
			if mag < 100 then
				print(mag)
				target = charhead.Parent
				targetting = true
				targetdist = mag
				coroutine.resume(coroutine.create(engage))
				coroutine.resume(coroutine.create(targettingDisable))
			end
		end
	end
end

Check the console for any errors when testing.

I have, like I said the code all runs

Make sure that the character isn’t anchored too.

Have you tried testing the MoveTo() call with an instance instead of a Vector3 value?

they arent anchored --------------------------------------------

I cant, it has to move to a random position not a part

I know, but have you tested if the function will work with a random position (to ensure that it isn’t the Vector3 value you’re attempting to use that is causing the issue).

i know that isn’t the issue since it works on my character