How do I make a CFRAME that keeps the parts orientation?

hello so bassically I want to tween a part however it also tweens the parents orientation

the tween wont work unless I use CFrame and I cant use Position.

I create the CFrame as so

local Pos = Workspace.Part.Position
local CF = CFrame.new(Pos) 
--  tween the CF here
-- excuse any errors, I wrote the code in dev forums.

however the orientation of the part gets tweened to 0,0,0 as well and I want to maintain the orientain

Please note the code snippet I gave was not my actual code but a simplified version.

2 Likes

CFrame.new(position,position+part.CFrame.LookVector) should work
if it’s oriented wrong still, try this:
CFrame.new(position,position+part.CFrame.LookVector,part.CFrame.UpVector)

1 Like

Just save the orientation in a variable and then after then tween is finished just change the part’s orientation to the variable.

1 Like

This is bad practice, it’s doing more work than necessary since it can all be done in the same CFrame operation.

Along side that, since they’re tweening it, the orientation would tween too, then just snap back to the correct one once the tween is done.

2 Likes

I honestly like my method. But I’m also pretty sure yours works so props to you :+1:

You’ve probably got more experience than I do so I’ll leave it how it is (cause I don’t want ppl getting suspicious over a deleted post).

1 Like
local function flight(pos)
    local tween = ts:Create(butterfly.PrimaryPart, TweenInfo.new(5, Enum.EasingStyle.Linear), {CFrame = CFrame.new(pos,pos+butterfly:GetPivot().LookVector,butterfly:GetPivot().UpVector)})
    tween:Play()
    tween.Completed:Wait()
end

Okay so bassically my script is the brain for a butterfly. This function controls is called when he flys to a flower.

For some reason the butterfly keeps flying to 0,0,0

Pos represents the position of the flower and is correct ( I did a print )

any help?

1 Like

You used @Hqsuperlabgames ‘a solution. Since I had the wrong answer, i think theyd be competent enough to help you.

I’m also not very good at math.

1 Like

they provided code, you did not.

Yes, I understand that. That’s why I’m saying you should ask them and not me.

Oh I read your post again and it seems like you suggested I change the orientation after the butterfly has already flied to the flower. The entire point of maintaining the orientation is because before the function I orientate the butterfly in the direction of the flower so I want the butterfly to keep being in the direction of the flower while its flying (or tweening)

Change CFrame.new to CFrame.lookAt, but keep the arguments the same.

Yes, please ask @Hqsuperlabgames now. I think my job here is complete (since I can’t provide anything else useful).

1 Like

I am not tweening the direction the butterfly is looking in, I am changing the position of the butterfly without changing the direction.

You are just being a jerk like nobody cares if you arent going to help stop trying to make us feel like we did something wrong.

I know, but lookAt gives it both a position and a look direction, which would be the new position and the new position+the way it was already facing. The upvector is optional but if you use it, don’t add the position to it, that will break the orienting.

And for the record, I’m sure doomed was just trying to be helpful, I got no bad vibes from him.

2 Likes

Huh? I wasn’t trying to make you feel bad. I’m not sure why’d you assume I was trying to do that. I was trying to be respectful.

    local tween = ts:Create(butterfly.PrimaryPart, TweenInfo.new(5, Enum.EasingStyle.Linear), {CFrame = CFrame.lookAt (pos,pos+butterfly:GetPivot().LookVector,butterfly:GetPivot().UpVector)})

like this?

Yes that should be correct, go ahead and test it

Eggcellent.hjiopwerhjaerhgipnertbjertbjnkertb

1 Like

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