How to Easily get the CFrame I need to multiply by

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.


code:

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

Thanks in advance!

1 Like

Attachments were made for this purpose , the same as humanoid accessories

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.

You could use the BodyBackAttachment (that is located inside the UpperBody) and apply some rotation

it will looks something like this

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.


The sword cframe changes but not correctly

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

My method uses normal welds or the new rigid constraint.

@kalabgs method uses weld constraints.

You cannot mix the 2 due to CFrames being in object space for normal welds and world space for weld constraint.

image
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?

Yep just rotate and the axis will match up.

Also for @kalabgs method the key is to use attachments WorldCFrame. Both should work in theory.

yooo thx so much it works lol, also thx @kalabgs

also, can i offset the weldconstraint? is there a way to do that?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.