I'm trying to create two weapons, both with a handle on it. So to be clear, I am making a single tool that has two weapons in it. I just cannot get it to work no matter what. I have tried welding the whole thing together and I've also tried to weld just the two weapons by themselves if that makes any sense. All I can say is that I have had no success with making these weapons go by my hands. The only thing that happens is the weapon goes into my right hand and that's it, but I don't want that to happen, i want one weapon in one hand and one weapon in the other hand. Please tell me what I am doing wrong.
If I put this code in a local script in the weapon, the handle goes in my hand... but literally nothing else, not even the other handle. I have named them correctly, handle and handle1.
player = game.Players.LocalPlayer character = player.Character LArm=script.Parent.Parent:WaitForChild("Left Arm") RArm=script.Parent.Parent:WaitForChild("Right Arm") function KaiWeld() local w1 = Instance.new("Weld") w1.Parent = script.Parent.Handle w1.Part0 = w1.Parent w1.Part1 = script.Parent.Handle-------- This is the weapon that goes in the character's Right hand w1.C1 = CFrame.fromEulerAnglesXYZ(1, 0, 0) * CFrame.new(RArm.Position.CFrame.new(0,0,0),0,0) local w2 = Instance.new("Weld") w2.Parent = script.Parent.Handle w2.Part0 = w2.Parent w2.Part1 = script.Parent.Handle1-------- This is the weapon that goes in the Character's Left hand w2.C1 = CFrame.fromEulerAnglesXYZ(0, 0, 0) * CFrame.new(LArm.Position.CFrame.new(0,0,0),0,0) end script.Parent.Equipped:connect(KaiWeld) script.Parent.Unequipped:connect(KaiWeld)
I also have this piece of code which basically keeps the weapon together. Without this, the weapon just falls apart and breaks. I don't know why, but this script won't let me choose the position of the handles and I want to be able to choose the position of EACH handle.
function weld() local parts,last = {} local function scan(parent) for _,v in pairs(parent:GetChildren()) do if (v:IsA("BasePart")) then if (last) then local w = Instance.new("Weld") w.Name = ("%s_Weld"):format(v.Name) w.Part0,w.Part1 = last,v w.C0 = last.CFrame:inverse() w.C1 = v.CFrame:inverse() w.Parent = last end last = v table.insert(parts,v) end scan(v) end end scan(script.Parent) for _,v in pairs(parts) do v.Anchored = false end end weld() script:Remove()
That should work. Just be sure that the script is in the weapon.
tool = script.Parent handle = tool:WaitForChild("Handle") Types = {"Part","WedgePart","TrussPart"} function Weld(obj) local w1 = Instance.new("Weld",handle) w1.Part0 = handle w1.Part1 = obj w1.C0 = handle.CFrame:inverse() w1.C1 = obj.CFrame:inverse() obj.Anchored = false end function Confirming() for _,part in pairs(tool:GetChildren()) do if part.Name ~= "Handle" then for _,type in pairs(Types) do if part:IsA(type) then Weld(part) end end end end handle.Anchored = false end Confirming()