Tween goes in weird directions before landing in its final position

Hi!. My goal is to open a vault by using Tween Service. My issue is that the tween does weird rotations and movements before landing in its final position. Below I have added a video.

The only solution i’ve thought of is tweening the vault in increments but the problem is that the tween would stop for a little bit and then continue (I would like a smooth tween instead of choppy)
- My current code

local ts = game:GetService("TweenService")

local VaultTweenInfo = TweenInfo.new(
	4,
	Enum.EasingStyle.Bounce,
	Enum.EasingDirection.Out,
	0,
	false
)

rep.VaultOpen.RedButtonPressed.OnClientEvent:Connect(function(vault)
	local goal = {
		Position = Vector3.new(130.6, 8.246, -19.036),
		Orientation = Vector3.new(0, -90, 90)
		-- THE VAULTS CURRENT ORIENTATION IS (0, 180, 90)
	}
	
	local TweenVault = ts:Create(vault, VaultTweenInfo, goal)
	
	TweenVault:Play()
	
end)
}

How would I go about fixing this? Thank you!

Can you send your code so we can actually fix it?

2 Likes

You might have the pivot point/root part in the wrong location making it rotate like that.

1 Like

My bad, here it is

local ts = game:GetService("TweenService")

local VaultTweenInfo = TweenInfo.new(
	4,
	Enum.EasingStyle.Bounce,
	Enum.EasingDirection.Out,
	0,
	false
)

rep.VaultOpen.RedButtonPressed.OnClientEvent:Connect(function(vault)
	local goal = {
		Position = Vector3.new(130.6, 8.246, -19.036),
		Orientation = Vector3.new(0, -90, 90)
		-- THE VAULTS CURRENT ORIENTATION IS (0, 180, 90)
	}
	
	local TweenVault = ts:Create(vault, VaultTweenInfo, goal)
	
	TweenVault:Play()
	
end)

I’m pretty sure it is because you used the tweening style bounce.

Edit: here are all the styles.

Easingstyle

Tweening is preformed on the center of the part. If you look at your animation, the center of the part is rotated to the goal.

If you want to tween around a different point than the center but still use the TweenService, you can do it like this:

  • Create another part in the location where you want the object to tween (in your case, position it like a hinge for the door).
  • Weld all the other parts to this “hinge” part
  • Unanchor all the other parts besides the hinge part. Make sure the hinge part is anchored.
  • Tween the CFrame value. Make the goal table something like this:
local hinge -- Set to the hinge part

local goal = {}
goal.CFrame = hinge.CFrame * CFrame.Angles(0,math.rad(90),0)
-- (90 is the degrees to rotate. -90 goes the other way)

Edit:
Here is related post:

There are also a few others. If you have any questions just let me know :happy2:

Try do vault.Orientation.Y+90, it should always turn just 90 degrees relative to itself, rather than trying to target a set value.
ezgif-6-2209d8360bdb

I tried this but there is an error saying “TweenService:Create property named ‘Orientation’ cannot be tweened due to type mismatch (property is a ‘Vector3’, but given type is ‘double’)”

Thank you for your help. It works!

1 Like

The tweening style isn’t the problem I believe. The problem is that the vault rotates the other way before going in its final position. Thank you for trying to help though :smiley: