Hi! I’m trying to weld a sword to a character’s left leg using the following script.
local function replicatedWeapon(c)
local replicatedsword = game.ReplicatedStorage.Replicas["Katana"]:Clone()
local handle = replicatedsword.Handle
local rp = c.HumanoidRootPart
local weld = Instance.new("Weld")
weld.Part0 = rp
weld.Part1 = handle
weld.C1 = CFrame.new(0.6, 1.2, -1.1) * CFrame.Angles(math.rad(-10),math.rad(90),math.rad(0))
weld.Parent = handle
replicatedsword.Parent = rp
end
local function removeWeapon(c)
local sword = c:FindFirstChild("Katana Replica")
if sword then
sword:Destroy()
end
end
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local weapon = p.Backpack:FindFirstChild("Katana")
if weapon then
replicatedWeapon(c)
end
p.Backpack.ChildAdded:Connect(function(s)
if s.Name == "Katana" then
replicatedWeapon(c)
end
end)
p.Backpack.ChildRemoved:Connect(function(s)
if s.Name == "Katana" then
removeWeapon(c)
end
end)
end)
end)
Unfortunately, the weld.C1 orientation does not copy to the character properly.
I would recommend using WeldConstraints over Welds. They are, in my opinion, the less complex version of Welds and they achieve the same thing. The creator hub even describes them as a newer alternative for those who don’t want to manually set the C0 and C1 properties.
Working with CFrame.Angles can be kind of hard, because the rotations are not composed in the same order as what you get if you put numbers into CFrame Orientation in the property panel. Angles does Tait-Bryan XYZ, CFrame.fromOrientation(x,y,z) does YXZ. From your screenshot, it does look like you want a 90 deg Y rotation then 10 deg X, and that’s not what CFrame.Angles is going to do. I would say just try using CFrame.fromOrientation as your first step. If it’s still wrong, it’s possibly a direction issue. Weld.C1 is harder to think about than C0 , because it’s the offset of the HRP from the sword, which is not how one naturally things about things (it’s the inverse).