I’m unable to get the models to behave correctly on the character.
I’m switching between WeldContrains and Motor6d. Neither of them bring acceptable results. Welding a model to a character should be a trivial thing to achieve, but it feels impossible to me.
Let’s go over the behavior with using WeldConstraints;
- Pros
- It positions the parts with their original position, which means that the parts within the model are positioned correctly.
- Cons
-
The parts welded to the arms move the opposite way of the character’s movement.
-
The parts don’t follow the character precisely enough, causing the HumanoidRootPart and arms to glitch through the parts welded to them.
Image of result:
Script method:
local function addConstraints(model,character,targetPart)
for index,part in pairs(model:GetDescendants()) do
if part:IsA("BasePart") then
local constraint = Instance.new("WeldConstraint")
constraint.Parent = part
constraint.Part0 = part
if targetPart.Name == "Head" then
constraint.Part1 = targetPart
elseif targetPart.Name == "HumanoidRootPart" then
local left = model:FindFirstChild("Left")
local middle = model:FindFirstChild("Middle")
local right = model:FindFirstChild("Right")
if part:IsDescendantOf(left) then
constraint.Part1 = character:FindFirstChild("Left Arm")
elseif part:IsDescendantOf(middle) then
constraint.Part1 = targetPart
elseif part:IsDescendantOf(right) then
constraint.Part1 = character:FindFirstChild("Right Arm")
end
end
end
end
end
modelToEquip:PivotTo(targetPart.CFrame)
addConstraints(modelToEquip,character,targetPart)
Now for the behavior when using Motor6D;
- Pros
- The parts welded to the arms are now moving in the correct direction.
- Cons
-
It does not position the parts at their original position, which means that the parts within the model are positioned at the targetPart (HumanoidRootPart or Head). Applying an offset seems to bring random results.
-
The parts don’t follow the character precisely enough, once again causing glitching, however it is worth mentioning that it glitches less than a WeldContraint.
Image of result:
Script method (important to note that I have tried most of the things on devforum, inversed offsets and so on. Of course if you have a code suggestion, I will test it. This is simply to inform that I have tried my best to find any sense in creating a proper offset.):
local function addConstraints(model,character,targetPart)
for index,part in pairs(model:GetDescendants()) do
if part:IsA("BasePart") then
local constraint = Instance.new("Motor6D")
constraint.Parent = part
constraint.Part0 = part
if targetPart.Name == "Head" then
constraint.Part1 = targetPart
elseif targetPart.Name == "HumanoidRootPart" then
local left = model:FindFirstChild("Left")
local middle = model:FindFirstChild("Middle")
local right = model:FindFirstChild("Right")
if part:IsDescendantOf(left) then
constraint.Part1 = character:FindFirstChild("Left Arm")
elseif part:IsDescendantOf(middle) then
constraint.Part1 = targetPart
elseif part:IsDescendantOf(right) then
constraint.Part1 = character:FindFirstChild("Right Arm")
end
end
constraint.C0 = ???
end
end
end
addConstraints(modelToEquip,character,targetPart)