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)
}
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
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’)”
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