Hey! So I’m trying to make a frame instance play an Elastic Easing but I want the property to remain untouched, so the frame just goes back and forth four times, like it would at the end of the Elastic Easing.
I have tried calling the TweenService function with the same property but of course it won’t work since the goal has already been reached. To be more exact, I want to tween the position of the object on the X axis.
Is it possible to achieve this without having to call the TweenService function a bunch of times? Since I’m pretty bad when it comes to tween styles.
The issue here stems from how TweenService calculates interpolation. It looks for a delta (difference) between the current state and the goal state. Since your Start Position and Goal Position are identical, the calculated distance is 0. Therefore, the engine has no path to apply the Elastic math to, resulting in no movement.
To achieve a “wobble in place” effect, you must artificially create a path for the Tween. The standard pattern for this is to instantly offset the Frame by a small amount (just before the tween starts), and then immediately tween it back to its OriginalPosition.
Here is the cleanest way to implement this pattern:
local TweenService = game:GetService("TweenService")
local frame = script.Parent -- Your Frame
local originalPos = frame.Position
local tweenInfo = TweenInfo.new(
1.5, -- Time
Enum.EasingStyle.Elastic,
Enum.EasingDirection.Out
)
local function playElasticEffect()
frame.Position = originalPos + UDim2.new(0, 50, 0, 0)
local tween = TweenService:Create(frame, tweenInfo, {Position = originalPos})
tween:Play()
end
-- Example usage
task.wait(2)
playElasticEffect()
This approach allows the property to effectively remain “untouched” in the long run (it always returns to originalPos) while still providing the necessary travel distance for the Elastic style to function