Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Zrxiis 26
4 years ago

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

Log in to vote
0
Answered by 4 years ago

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
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 Zrxiis 26 — 4y
0
try playing around with the order of the part0 and part1 properties of the weld and use C0 and C1 Code1400 75 — 4y
Ad
Log in to vote
0
Answered by
Zrxiis 26
4 years ago

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)

Answer this question