so i try to do this formula to solve for the C0:
weld.C0 = weld.Part0.CFrame:inverse() * weld.Part1.CFrame * weld.C1
however, when i set the world to part0 and part1, part1 goes to part0 making this formula unreliable.
Im using this as i have a vehicle that i want to weld together, and im using this script in the command bar:
local jet = workspace.Jet
for i, v in pairs(jet:GetChildren()) do
if v:IsA("BasePart") or v:IsA("MeshPart") and v.Name ~= "PRIMARYPARTVERYIMPORTANT" then
weld = Instance.new("Weld")
weld.Parent = v
weld.Part0 = jet.PRIMARYPARTVERYIMPORTANT
weld.Part1 = v
local offset = jet.PRIMARYPARTVERYIMPORTANT.CFrame * weld.Part1.CFrame * weld.C1
weld.C0 = offset
end
end
local jet = workspace.Jet
for i, v in pairs(jet:GetChildren()) do
if (v:IsA("BasePart") or v:IsA("MeshPart")) and v.Name ~= "PRIMARYPARTVERYIMPORTANT" then
local weld = Instance.new("Weld")
weld.C0 = jet.PRIMARYPARTVERYIMPORTANT.CFrame:Inverse() * v.CFrame
weld.Part0 = jet.PRIMARYPARTVERYIMPORTANT
weld.Part1 = v
weld.Parent = v
end
end
when you put Part0 and Part1, C0 and C1 are applied automatically, so it is better to configure it before selecting the parts.
local jet = workspace.Jet
for i, v in pairs(jet:GetChildren()) do
if v:IsA("BasePart") or v:IsA("MeshPart") and v.Name ~= "PRIMARYPARTVERYIMPORTANT" then
local offset = jet.PRIMARYPARTVERYIMPORTANT.CFrame:Inverse() * v.CFrame
local weld = Instance.new("Weld")
weld.Parent = v
weld.Part0 = jet.PRIMARYPARTVERYIMPORTANT
weld.Part1 = v
weld.C0 = offset
end
end
I figured it out when u said get the offset before the weld is set