Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to move an objects cframe while using toObjectSpace()?

I'm trying to move a sheathed sword that I welded to the players torso but when I try it doesn't move?

local sheathe = sheathedSword:FindFirstChild("Sheathe")
sheathe.CFrame = char.Torso.CFrame
sheathe.CFrame:ToObjectSpace(char.Torso.CFrame - Vector3.new(0, 5, 0)
sheathe.CFrame = sheathe.CFrame * CFrame.Angles(math.rad(-70.33), math.rad(0), math.rad(-90))	
createWeldConstraint(char.Torso, sheathe)

2 answers

you dont need to use toObjectSpace since you are refrencing the parts cframe you want it to go to. just do


sheathe.CFrame = char.Torso.CFrame * CFrame.new(0,5,0) -- you may have to play with these values

2 comments

0

I tried just using the part CFrame before but when I create the sheathe model it ends up in different places depending on which direction im facing

0

try playing around with the order of the part0 and part1 properties of the weld and use C0 and C1

So what I did to fix the problem and make it appear in the same position no matter the character's rotation was CFrame:ToWorldSpace()

https://developer.roblox.com/en-us/articles/object-world-space

local sheathe = sheathedSword:FindFirstChild("Sheathe")
	sheathe.CFrame = char.Torso.CFrame
`	--Create the offset you want
	local offset = CFrame.new("Your offset")
	--Make the CFrame relative to the world position of the torso
	sheathe.CFrame = char.Torso:ToWorldSpace(offset)
	sheathe.CFrame = sheathe.CFrame * CFrame.Angles(math.rad(-70.33), math.rad(0), math.rad(-90))  
	createWeldConstraint(char.Torso, sheathe)

This discussion is preserved as it was. New answers, comments, and votes are closed.