# Help with Tweening

I want to make a frame tween until it reaches it’s goal.

``````local function getTweenSpeed(goalSize, duration)
local speed = (duration / goal.X.Scale)
print(speed)
return speed
end

local speed = getTweenSpeed(goal, 10)
local tweenInfo = TweenInfo.new(speed, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local tween = TweenService:Create(bar, tweenInfo, {Size = goal})
tween:Play()
``````

Can you describe the issue? What are you expecting to happen and what happens instead?

I want it to tween until it reaches it’s goal. I want the speed to depend on the duration.

The first argument of TweenInfo.new() is how long you want the tween to take. Pass in duration there instead of speed.

Now what do I do with speed then?

It’s useless in this case. TweenInfo takes in duration, not the speed.

Duration is the speed that it goes in.

No, duration is the amount of time it takes to finish the tween. Speed is a measurement of how fast it goes, not how long it takes to reach the end.

The original question was how to get a tween to end in a specific amount of time, and I answered. Their speed calculation is useless here.

Yes, the Speed that it goes in

Example: if you set the Duration to `2`, it move at a very slow speed, at `.5`, it will be very fast

They’re not the same thing. Duration of 2 means it’ll take 2 seconds to reach the end. Speed is distance over time. Duration is time.

I’m not sure why you brought this up in the first place, it’s unrelated.

try flipping them

``````local speed = (goal.X.Scale / duration)
``````

However, this can cause them to go too fast

This is not useful. They want the tween to take X amount of time, they don’t need a speed calculation.

You arent being very helpful either, plus why are you even arguing here, you are basically filling this with off topic stuff. Send a Message, not a Reply.

i used chatGPT for this bcs its not an essay, its code (fyi)

``````
local function getTweenSpeed(currentSize, goalSize, duration)
local distance = (goalSize - currentSize).Magnitude
local speed = distance / duration
return speed
end

local currentSize = bar.Size
local goalSize = Vector2.new(100, 100) -- replace with your goal size
local duration = 10 -- replace with your desired duration

local speed = getTweenSpeed(currentSize, goalSize, duration)
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local tween = TweenService:Create(bar

``````

a few issues with the code that u provided:

1. In the `getTweenSpeed` function, `goalSize` parameter is used instead of `goal.X.Scale` . Also, you should use `goalSize.X.Scale` instead of `goal.X.Scale` .
2. In the `getTweenSpeed` function, you are dividing the duration by the X scale of the goal size. This might not be correct if the goal size is not proportional to the current size of the frame. You could consider using the distance between the current size and the goal size instead.
3. In the `TweenService:Create` method, you are passing `goal` instead of `goalSize` as the target size.’

I looked it over i think its right

It looks like you are trying to create a TweenService to tween the Size of a frame until it reaches a goal size. However, there are a couple of issues with your code that may prevent it from working as intended.

Firstly, in your getTweenSpeed function, you are dividing the duration by goal.X.Scale, but goal is actually a vector3 value, so you need to access the X component of the vector3 by using goal.X instead. Additionally, you may want to consider using the magnitude of the vector3 (i.e. goal.Magnitude) instead of just the X component, as this will give you a more accurate measure of the distance between the current size and the goal size.

Secondly, when you call getTweenSpeed, you are passing goal as the first argument, but it should be goal.Size instead, since that is the property you are trying to tween.

Here’s an updated version of your code that should work correctly:

``````local function getTweenSpeed(goalSize, duration)
local speed = duration / goalSize.Magnitude
return speed
end

local goalSize = Vector3.new(100, 100, 100) -- replace with your desired goal size
local speed = getTweenSpeed(goalSize, 10)
local tweenInfo = TweenInfo.new(speed, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)
local tween = TweenService:Create(bar, tweenInfo, {Size = goalSize})
tween:Play()
``````

Note that you will need to replace goalSize with your desired goal size, and bar with the actual frame object you want to tween.