Hello, I am working on a weapons system and I need to get the cframe needed to multiply by in order to get the positioning correct…does anyone know of an easy way so I do not have to guess everytime until I get it right? The first image is the position I am trying to achieve and the second is what the code does so far.
function module.equip(HRP, character)
local Torso = character.UpperTorso
if Torso and HRP and character then
print("activated")
local SheathedPos = SwordMesh:GetAttribute("SheathedPos")
local SwordModel = SwordMesh:Clone()
SwordModel.Name = "Sheathed_Iron_Sword"
SwordModel.Handle.CFrame = Torso.CFrame --* SheathedPos
SwordModel.Parent = character
SwordModel.Handle.Anchored = true
local weld = Instance.new("WeldConstraint")
weld.Part0 = Torso
weld.Part1 = SwordModel.Handle
weld.Parent = character
end
end
Why not just create a motor6D and edit it in studio until you have the desired cframe. After this, remove the part 1 or just set it to nil. Then after just clone the sword and set it to the specific body part that matched the original part 1 on the motor6D.
function module.equip(HRP, character)
local Torso = character.UpperTorso
if Torso and HRP and character then
print("activated")
local SheathedPos = SwordMesh:GetAttribute("SheathedPos")
local SwordModel = SwordMesh:Clone()
SwordModel.Name = "Sheathed_Iron_Sword"
SwordModel.Handle.CFrame = Torso.BodyBackAttachment.WorldCFrame * CFrame.Angle(math.pi/2, 0, 0) -- tweak the orientation to match your expectations this is only an example
SwordModel.Parent = character
SwordModel.Handle.Anchored = true
local weld = Instance.new("WeldConstraint")
weld.Part0 = Torso
weld.Part1 = SwordModel.Handle
weld.Parent = character
end
end
alright so I am sort of doing half and half. I chose to add an attachment called sheathed to the sword, and I took FartFellas idea of welding it to the BodyBackAttachment but when I do that I get this result.
function module.equip(HRP, character)
local Torso = character.UpperTorso
if Torso and HRP and character then
print("activated")
local SwordModel = SwordMesh:Clone()
local CharacterAttachment = character.UpperTorso.BodyBackAttachment
local SwordAttachment = SwordModel.iron_Sword.SheathedPos
SwordModel.Name = "Sheathed_Iron_Sword"
SwordAttachment.CFrame = CharacterAttachment.CFrame
SwordModel.Parent = character
local weld = Instance.new("WeldConstraint")
weld.Part0 = Torso
weld.Part1 = SwordModel.Handle
weld.Parent = character
end
end
your right, im using your method fully now and it works, I just need to get the rotation down then, and I can do that by just rotating the attachment right?