Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how do you weld a sword?

Hello biocommand here with a really doubt thats been bothering me long time ago, so I am trying to make a really cool sword with complex figures with Solid modeling and I want actually to work, bit I was wondering how do I make all parts stay together without anchoring them?

1 comment

0

Just use Solid modeling and make it 1 part. But if you don't want to do that look up Welds on the wiki.

2 answers

✓ Accepted answer

Use an auto-weld script: (Place this inside the model)

local weldTo = script.Parent.INSERTNAMEOFTHEMAINPART
local weldToCf = weldTo.CFrame:inverse()
 
local parts = {weldTo}
 
function Weld(parent)
        for _,v in pairs(parent:GetChildren()) do
                if (v:IsA("BasePart") and v ~= weldTo) then
                        local w = Instance.new("Weld")
                        w.Name = "SwordWeld"
                        w.Part0 = weldTo
                        w.Part1 = v
                        w.C0 = weldToCf
                        w.C1 = v.CFrame:inverse()
                        w.Parent = weldTo
                        table.insert(parts, v)
                end
                Weld(v)
        end
end
 
 
 
Weld(script.Parent)
 
for _,v in pairs(parts) do
        v.Anchored = false
end
 
script:Destroy()

1 comment

0

Oh, and make sure all the parts are anchored. This script will automatically weld everything together and unanchor everything

function Weld(x,y) local W = Instance.new("Weld") W.Part0 = x W.Part1 = y local CJ = CFrame.new(x.Position) local C0 = x.CFrame:inverse()*CJ local C1 = y.CFrame:inverse()*CJ W.C0 = C0 W.C1 = C1 W.Parent = x end

function Get(A) if A.className == "Part" or A.className == "UnionOperation" then Weld(script.Parent.Handle, A) A.Anchored = false else local C = A:GetChildren() for i=1, #C do Get(C[i]) end end end

function Finale() Get(script.Parent) end

script.Parent.Equipped:connect(Finale) script.Parent.Unequipped:connect(Finale) Finale()

This script supports UnionOperations aswell AKA solid modeling.

This discussion is preserved as it was. New answers, comments, and votes are closed.