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?
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()
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.