Vector3 tween misplacing model

I have recently been using this module to tween models, and it has been working for some models, except this one below. I am using Vector3 to tween the model but it offsets itself by a couple studs then tweens.

You can find the module in the link above, but I doubt that the module is the issue and it is because of my code

local doorinfo = TweenInfo.new(.85, Enum.EasingStyle.Quart)

while true do
	module.TweenModulePosition(doorL,doorinfo,Vector3.new(2.93, 0, 0))
	wait(3.5)
	module.TweenModulePosition(doorL,doorinfo,Vector3.new(-2.93, 0, 0))
	wait(3.5)
end

(the while true do is for debugging purposes)

Anyone know how to fix this?

Try setting the TweenInfo’s TweenInfo.TweenType to Enum.TweenType.Quart instead of Enum.TweenType.Quad.

Does that module automatically set the position in object space? I’m gonna guess it does not, you are just setting the position in world space, you have to give the position you want to offset from.

local doorLDefaultPosition = doorL.Position --save the default position on a variable
local doorinfo = TweenInfo.new(.85, Enum.EasingStyle.Quart)

while true do
	module.TweenModulePosition(doorL,doorinfo,doorLDefaultPosition + Vector3.new(2.93, 0, 0))
	wait(3.5)
	module.TweenModulePosition(doorL,doorinfo,doorLDefaultPosition)
	wait(3.5)
end

Wouldn’t I have to use CFrame and GetPivot() to access model positions?

If it’s a model then yes, just swap the default position variable with the pivot position and it should work:

local doorLDefaultPosition = doorL:GetPivot().Position

It works, but the only problem with this is that I have to change the 2.93 to the Z axis when rotating the door, is there a more efficient way to do this?

Are you trying to change the position and orientation in a single tween? It’s best to tween the CFrame then, if that’s not what you want then please explain more.

Yeah sorry, I should’ve specified more, I thought Vector3 was the same as CFrame so I figured it would work regardless

If you want to tween the CFrame then just make a few adjustments

local doorLDefaultPosition = doorL:GetPivot() --save the CFrame instead
module.TweenModuleCFrame(doorL,doorinfo,doorLDefaultPosition * CFrame.new(THE_OFFSET_POSITION) * CFrame.Angles(0, math.rad(THE_OFFSET_ROTATION_IN_ANGLES), 0)) --call the proper module function, im not too familiar with this module
module.TweenModuleCFrame(doorL,doorinfo,doorLDefaultPosition) --to return

How would I use the CFrame.Angles function? Am I not just tweening left and right?

I thought you wanted to change the orientation as well? If you only wanted to change the offset then keep the original code and just change the offset on this line:

module.TweenModulePosition(doorL,doorinfo,doorLDefaultPosition + Vector3.new(2.93, 0, 0))

Sorry for the late reply, but my problem is that when I rotate the door, the 2.93 apparently gets changed on the Z axis instead of the X axis (as you can see here)

Is there a way the doors can move side to side without it moving weirdly when I move the entire model?

Oh I see, in that case you want to use CFrame as it will account the rotation, something like this:

local doorLDefaultCFrame = doorL:GetPivot()
local doorinfo = TweenInfo.new(.85, Enum.EasingStyle.Quart)

while true do
	module.TweenModuleCFrame(doorL,doorinfo,doorLDefaultPosition * CFrame.new(2.93, 0, 0)) --call the proper module function, im not too familiar with this module
	wait(3.5)
	module.TweenModulePosition(doorL,doorinfo,doorLDefaultPosition)
	wait(3.5)
end

I actually managed to finally figure this out by using this helpful tutorial (although it took me more than 17 tries in the past couple months). Thanks for your help though!

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