How do I Move A Model in a script?

Hello, I’m trying to make it so a monster moves towards a player. I have this fully rigged (I think) monster. The monster rig I made myself and I also rigged myself so IDK if I did it wrong or something. I just used motor6ds and welds. Anyways I have a path finding script but it always says

Enum.PathStatus.NoPath

My script is:

local function Attack()
	print("attacking")
	while target ~= nil do
		task.wait() 
		
		local path : Path = PFS:CreatePath({
			AgentRadius = 3,
			AgentHeight = 6,
			AgentCanJump = true,
			Costs = {
				Water = 20
			}
		})
		
		local success, result = pcall(function()
			path:ComputeAsync(monster.HumanoidRootPart.Position, target.Character.HumanoidRootPart.Position)
		end)
		
		if success and path.Status == Enum.PathStatus.Success then
			for _, waypoint : PathWaypoint in pairs(path:GetWaypoints()) do
				hum:MoveTo(waypoint.Position)
				hum.MoveToFinished:Wait()
			end
		else
			print(path.Status)	-- prints Enum.PathStatus.NoPath 24/7
		end
	end
end

Here is my monster model:
image
image


The entire monsters body is welded to one main body piece. That main body piece is connected to the humanoidrootpart via a motor6d. there is also a weld constraint connecting a part named eyes to the humanoidrootpart.

You can also find the model here:

Does there happen to be a Humanoid parented to the workspace?

This is a really good way to get people to help you.

image
this is an image of the model. I have a humanoid inside of it.

Thanks it worked. btw how do I make my monster not so trash? it looks really poorly made. (I tried breaking the loop so it wouldnt waste time going to a spot the player wasnt already there.) Here is the code:

local function Attack()
	
	while target ~= nil do
		print("attacking")
		
		local path : Path = PFS:CreatePath({
			AgentRadius = 3,
			AgentHeight = 6,
			AgentCanJump = true,
			Costs = {
				Water = 20
			}
		})
		
		local success, result = pcall(function()
			path:ComputeAsync(monster.HumanoidRootPart.Position, target.Character.HumanoidRootPart.Position)
		end)
		
		if success and path.Status == Enum.PathStatus.Success then
			for _, waypoint : PathWaypoint in pairs(path:GetWaypoints()) do
				hum:MoveTo(waypoint.Position)
				hum.MoveToFinished:Wait()
				if _ == 5 then
					break
				end
			end
		else
			print(path.Status)
			print(success)
			print(result)
			
		end
	end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.