I was wondering on how you would merge these two scripts together. The weld to back script welds the tool (only a part) onto the back part of the torso on a player while the tool weld script allows parts to be connected together. I've been studying this script for a long period of time but it does not seem to be working. Any help?
Weld to Back:
handle = nil
function onUnequipped()
if script.Parent.Parent == workspace or script.Parent.Parent.className ~= "Backpack" then
if handle ~= nil then
handle:remove()
end
return
end
local char = script.Parent.Parent.Parent.Character
if char ~= nil then
local torso = char:findFirstChild("Torso")
local tool = char:findFirstChild(script.Parent.Name)
if torso ~= nil and tool == nil then
handle = script.Parent.Handle:clone()
handle.CanCollide = false
handle.Name = script.Parent.Name
handle.Parent = char
local weld = Instance.new("Weld")
weld.Name = "BackWeld"
weld.Part0 = torso
weld.Part1 = handle
weld.C0 = CFrame.new(0,0,0.6)
weld.C0 = weld.C0 * CFrame.fromEulerAnglesXYZ(math.rad(90),math.rad(30),0)
weld.Parent = handle
elseif torso ~= nil and tool ~= nil then
if tool.className == "Part" then
handle = tool
tool.Transparency = script.Parent.Handle.Transparency
end
end
end
end
script.Parent.Unequipped:connect(onUnequipped)
function onEquipped()
if handle ~= nil then
handle.Transparency = 1
end
end
script.Parent.Equipped:connect(onEquipped)
Tool Weld:
local BrickTable = {}
function RecursiveGeneric(Parent, Func, ClassLimit)
for _, Child in pairs(Parent:GetChildren()) do
if not ClassLimit or Child:IsA(ClassLimit) then
Func(Child)
end
RecursiveGeneric(Child, Func, ClassLimit)
end
end
RecursiveGeneric(
script.Parent,
function(Brick) table.insert(BrickTable, Brick) end,
"BasePart"
)
local Base = BrickTable[1]
table.remove(BrickTable, 1)
for _, Part in pairs(BrickTable) do
local Weld = Instance.new("Weld")
Weld.Part0 = Base
Weld.Part1 = Part
Weld.C1 = Part.CFrame:inverse() * Base.CFrame
Weld.Parent = Base
Part.Anchored = false
end
Base.Anchored = false
