Welding HumanoidRootPart

Hey there, so I’m trying to manipulate this function as for pets. Seeing my pet system uses the same thing.

I have no idea how to add welds like this and I’ve tried finding tutorials on it. I need to weld the parts so they will actually add into the game.

Does anybody happen to know how to add welds like this such as shown in Studio Explorer.

I’ve tried inserting welds myself but I’m not sure how that would even connect it to another part via “Insert Object”

Thanks!

(I wasn’t sure if I should put this in Scripting Support or Building Support seeing it’s pretty relevant to both seeing my scripts are what utilize this.)

Script for adding pets:

local plpe = {}
local rplr = game.Players.LocalPlayer
local rchar = rplr.CharacterAdded:Wait()

game.ReplicatedStorage.Remotes.NewClientPet.OnClientEvent:Connect(function(i)
for a, v in pairs(i.Pets) do
	if type(a)=="string" then return end
	local hrp = v:FindFirstChild("HumanoidRootPart")
	hrp.Anchored = true
  end
plpe[i.Player.Name] = i
end)

game:GetService("RunService").RenderStepped:connect(function()
for plrName, i in pairs(plpe) do
	local vw = #i.Pets
	local angle = math.pi*2/(vw)
	
	local plr = i.Player
	if not plr.Parent then
		i=nil
		return
	end
	local char = plr and plr.Character
	if char then
		local hum = char:FindFirstChild("Humanoid")
		local hrp = char:FindFirstChild("HumanoidRootPart")
		if hrp and hum then
			
			for ii, v in pairs(i.Pets) do
				v.PrimaryPart = v.HumanoidRootPart
				local ve = Vector3.new(
					math.cos(angle*(ii-1)+(tick()/10))*math.max(5, vw), 
					2, 
					math.sin(angle*(ii-1)+(tick()/10))*math.max(5, vw)
				)+Vector3.new(0,math.sin(tick()/10/vw*ii),0)
				v:SetPrimaryPartCFrame(hrp.CFrame+ve)
			end
		end
	end
end 
end)

It likes to say “HumanoidRootPart” not a valid member of model - and when I check it while running a test in studio - this is what shows:

Meanwhile this error keeps spam displaying:

Screenshot_11

Thanks!

You could try setting the model’s PrimaryPart to the HumanoidRootPart and accessing it via Model.PrimaryPart

What I would do is iterate through all of the parts in the model, and then create a WeldConstraint between the current part in the loop and the model’s PrimaryPart. WeldConstraints take away all of the hassle of using CFrames to weld two parts together.