MoveTo is not a valid member of part

Hello there! I have a little problem with my script. It gives an error in output. I do not know how to fix it tho.

  1. What is the issue? the issue is that it comes up with an error an it says *MoveTo is not a valid member of Part “Workspace.Zombies.Zombie.HumanoidRootPart”

  2. What solutions have you tried so far? I have looked through devforum and can not find anything that is helpful! Here is the script:

while wait(1) do
zombieHuman:MoveTo(game.Workspace[“2_P90”].HumanoidRootPart.Position)

end
Please tell me what is wrong with this script!

3 Likes

MoveTo only works in the Humanoid and not the parts of a Character.

MoveTo requires a Humanoid, not a humanoidrootpart.

But the character under “Workspace” says that the player is a HumanoidRootPart.

Try doing:

local Humanoid = workspace.Zombies.Zombie.Humanoid

while wait(1) do
    Humanoid:MoveTo(game.Workspace[“2_P90”].HumanoidRootPart.Position)
end

Im just gonna say now that workspace.Zombies is a folder in workspace the zombie itself is in ServerStorage.

Lemme just give you all the whole script k?

local char = game.Workspace:WaitForChild(“2_P90”)

local zombie = script.Parent
local zombieHuman = zombie:WaitForChild(“HumanoidRootPart”)

local hitbox = zombie:WaitForChild(“HitBox”)

local damage = 30
hitbox.Touched:Connect(function(hit)
if hit.Parent then
local human = hit.Parent:FindFirstChild(“Humanoid”)
if human and hit.Parent.Name ~= “Zombie” then
human.Health = human.Health - 5
end

	if hit.Name == "Bullet" then
		zombieHuman.Health = zombieHuman.Health - damage
		hit:Destroy()
		if zombieHuman.Health <= 0 then
			_G.deadZombies = _G.deadZomb + 1
			zombie:Destroy()
		end
	end
end

end)

local ServerStorage = game:GetService(“ServerStorage”)
local Humanoid = ServerStorage.Zombie.Humanoid

while wait(1) do
Humanoid:MoveTo(game.Workspace[“2_P90”].Humanoid.Position)
end

I fixed it! all i did was this
local zombieHuman = zombie:WaitForChild(“Humanoid”)

local zombieHumanRootPart = zombie:WaitForChild(“HumanoidRootPart”)
and also this
while wait(1) do
zombieHuman:MoveTo(game.Workspace[“2_P90”].HumanoidRootPart.Position)