What do you want to achieve?
I’m currently making a hood system that welds a model to your head, the method im currently using involves manually welding parts to the MainPart of the model using a plugin
I was wondering if I could do that automatically from a script
What is the issue?
I tried to weld the parts from a script in server script service but it didnt turn out well, the parts change their cframe regardless of what i try to do
Should look like:
How it turned out:
3. What solutions have you tried so far?
I tried using the C0 property but it still did not fix it and I tried putting the part inside of the main part
for i, v in pairs(game.ServerStorage.Hoods:GetDescendants()) do
if v:IsA("BasePart") then
if v.Name == "MainPart" then
for x,z in pairs(v:GetChildren()) do
if not z:IsA("SpecialMesh") then
local weld = Instance.new("Weld")
z.CFrame = v.CFrame
weld.Part0 = v
weld.Part1 = z
weld.C0 = z.CFrame:Inverse() * v.CFrame
weld.Parent = z
for i, v in next, Hat:GetChildren() do
if v ~= Hat.PrimaryPart then
local Weld = Instance.new("Weld")
Weld.Part0 = v
Weld.Part1 = Hat.PriamryPart
Weld.C0 = v.CFrame:inverse()
Weld.C1 = Hat.PrimaryPart.CFrame:inverse()
Weld.Parent = Hat.PrimaryPart
The hat must have a PrimaryPart though.
EDIT: @Arcilios Are you trying to weld the hat to the head, or all the parts in the hat to the hat’s hitbox / primarypart?
wouldn’t using weldconstraint’s be much easier or would it not work with this?
If you can, here’s a script that might work. (sorry for my bad coding lol)
local descendants = script.Parent:GetDescendants()
for index, descendant in pairs(descendants) do
if descendant.ClassName == "Script" then
local weld = Instance.new("WeldConstraint", descendant)
weld.Part0 = descendant
weld.Part1 = script.Parent.PrimaryPart