Motor6d scripting, need help

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    i have an autorigger script works perfectly exept 1 small issue

  2. What is the issue? Include screenshots / videos if possible!
    whenever i weld 2 parts with a motor 6d (for animation purposes) the motor6d has C0 and C1 to 0,0,0 wich causes all the part to be in the same place,i would like to make it so the parts stay in place after welding, a bit like moon animator easy weld

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i have tried looking for solutions but most of them weren’t the error i had
    here is the auto script in question, inside the weld function is were i probably need help

local function weld(part0,part1)
	local weld = Instance.new("Motor6D")
	weld.Part0 = part0
	weld.Part1 = part1
	weld.Parent = part0
	weld.Name = part1.Name
end
for i,model in script.Parent:GetChildren() do
	if model:IsA("Model") then

		for i,part in model:GetDescendants() do
			if part.Parent.Name == "Clothing Model" then
				part.Parent = model
			end
		end
		local hrp = model.Torso:Clone()
		hrp.Parent = model
		hrp.CFrame = model.Torso.CFrame
		hrp.Name = "HumanoidRootPart"
		model["Clothing Model"]:Destroy()
		weld(model.HumanoidRootPart,model.Torso)
		for i,part in model:GetChildren() do
			if part:IsA("Part") then
				if part.Name ~= "HumanoidRootPart" and part.Name ~= "Torso" then
					weld(model.Torso,part)
				end
			end
		end
		for i,thing in model:GetChildren() do
			if thing:IsA("Model") then
				for i,part in thing:GetChildren() do
					if part.Name ~= "Middle" then
						weld(thing.Middle,part)
					end
				end
			end
		end
		for i,part in model:GetChildren() do
			if part.Name == "Left Leg" then
				weld(part,model.Leg1.Middle)
			end
			if part.Name == "Right Leg" then
				weld(part,model.Leg2.Middle)
			end
			if part.Name == "Left Arm" then
				weld(part,model.Arm1.Middle)
			end
			if part.Name == "Right Arm" then
				weld(part,model.Arm2.Middle)
			end
			if part.Name == "Torso" then
				weld(part,model.Chest.Middle)
			end
			if part.Name == "Head" then
				weld(part,model.Helmet.Middle)
			end
		end
		for i,part in model:GetDescendants() do
			if part:IsA("BasePart") then
				part.Anchored = false
			end
		end
	end
end
2 Likes

Motor6ds/welds cause the 2 connected parts to go into the same position by default.

You can use C0/C1 to offset them by however you want:

Motor6D.C0 = CFrame.new(0,2,0) -- 2 studs above original pos for part0

Also, unless you want animations to be added. There’s no need to use a motor6d/weld.

A simpler way would simply be to use a weldconstraint instead, which by default will not set the 2 parts into the same pos.

1 Like

i do want animations, since im autorigging all the rigs, however they are already in the default roblox stance, exept when i rig them they become into blocks all parts into 1 position, i want to make it so i can add a motor6d and fix it so the 2 parts stay in place while unanchored (aka setting C1/C0 to be in the correct place)

2 Likes

image

3 Likes
local cf = part1.CFrame:ToObjectSpace(part0.CFrame):Inverse()

turns out i had to use this magical line for some reason ;-;

2 Likes

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