Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do you weld a sword?

Asked by 9 years ago

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?

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. Perci1 4988 — 9y

2 answers

Log in to vote
0
Answered by
RAYAN1565 691 Moderation Voter
9 years ago

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()
0
Oh, and make sure all the parts are anchored. This script will automatically weld everything together and unanchor everything RAYAN1565 691 — 9y
Ad
Log in to vote
0
Answered by
Pixxels 45
9 years ago

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.

Answer this question