How to rig a model with a script?

Hello I have a pet model that i want to rig so I can use moveTo with it in pathfinding.

What I know

  • Everything must be welded in the model
  • There needs to be an object called “Head”
  • There needs to be a humanoidRootPart
  • there needs to be a humanoid.

I tried doing this in this code:

local function rigModel(petModel)
	
	local HumanoidRootPart = Instance.new("Part")
	HumanoidRootPart.Parent = petModel
	HumanoidRootPart.Name = "HumanoidRootPart"
	HumanoidRootPart.Size = Vector3.new(2,2,2)
	HumanoidRootPart.Position = petModel:GetPivot().Position
	petModel.PrimaryPart = HumanoidRootPart

	local humanoid = Instance.new("Humanoid")
	humanoid.Parent = petModel
	
	for i,v in pairs(petModel:GetChildren()) do
		if v:IsA("BasePart") then
			local weld = Instance.new("WeldConstraint")
			weld.Parent = v
			weld.Part0 = petModel.HumanoidRootPart
			weld.Part1 = v
			if v.Name ~= "HumanoidRootPart" then
				v.Anchored = false
			end
		end
	end
end

However when I try to use the code to pathfind the pet does not move.

Here is my pathfinding code:

local function walkTo(plr, pet, bedID)

	local path = pathFindingService:CreatePath()
	path:ComputeAsync(pet:GetPivot().Position, bedobject:GetPivot().Position)
	
	for i,v in pairs(path:GetWaypoints()) do
		pet.Humanoid:MoveTo(v.Position)
		wait(0.1)
	end
direction.Z))
end
1 Like

i mean you could like make the script create Motor6Ds to rig the pet but like why cant you do that outside of the script

im pretty sure you could make your own pathfinding i doubt it’s THAT hard