Whats the difference between TweenService's :Create and :SmoothDamp?

The title is pretty self explanatory.

:SmoothDamp() was added in the latest release of Studio, and I am really curious on what it does compared to :Create(). Can someone show me a use case between the 2 besides :SmoothDamp() just being a simpler version? That is the way I see it right now.

Thank you in advance!

1 Like

Tweens
Create() makes a new Tween instance that you can play, pause, cancel, and track the status of:

-- Get tween service
local TweenService = game:GetService("TweenService")

-- Create a part for our example
local target = Instance.new("Part")
target.Anchored = true
target.Position = Vector3.new(0, 5, 0)
target.Parent = workspace

-- Make settings
local tweenInfo = TweenInfo.new( -- This describes how the tween will reach its goal
	1, 							 -- This is how long the tween takes to complete if it isn't paused or cancelled
	Enum.EasingStyle.Linear,	 -- This is the easing style of the tween, more on that in its documentation
	Enum.EasingDirection.In,	 -- This is the easing direction of the tween, which is also explained in the docs
	0, 							 -- This is an optional number that lets us choose how many times the tween repeats
	true, 						 -- This is an optional boolean that lets us make our tween reverse automatically after reaching its goal
	0 							 -- This is an optional number that determines how long of a delay there is between tween repeats
)

-- Make our properties
local properties = {
	Position = Vector3.new(0, 10, 0),  -- This tells our tween to move the part to the position 0, 10, 0 when it fully reaches the goal
	Color = Color3.fromRGB(255, 0, 0), -- This tells our tween to make the part red when it fully reaches the goal
}

-- Assemble the tween
local tween: Tween = TweenService:Create(target, tweenInfo, [properties]) -- Now that we have our goals and settings, we can build our tween

tween:Play() -- To play our tween we use tween:Play()

tween.Completed:Connect(function(playbackState: Enum.PlaybackState)  -- This method tells us when the tween completes or cancels
	if playbackState == Enum.PlaybackState.Completed then -- If the tween completed successfully and wasn't cancelled, then
		print("Tween completed successfully!") -- Let us know the tween completed!
	end
end)

Smooth Damp
:SmoothDamp() is a one-time thing (at least as far as I’m aware) and I’m pretty sure it works as follows:

-- Get tween service
local TweenService = game:GetService("TweenService")

-- Create a part for our example
local target = Instance.new("Part")
target.Anchored = true
target.Position = Vector3.new(0, 5, 0)
target.Parent = workspace

-- Using :SmoothDamp()
TweenService:SmoothDamp(
	target.Position, 		-- The current value of the property you want to change
	Vector3.new(0, 10, 0), 	-- The target value / what you want the value to change to
	1, 						-- The velocity of the SmoothDamp
	1,						-- The total time it takes to reach the target value
	10						-- An optional max speed that the property can change at
) 							-- Not too sure what it returns since it's unreleased and not fully documented 😅

:SmoothDamp() isn’t able to be used in game development quite yet, and as mentioned, the docs for it aren’t fully up either. If you want to use it before it’s implemented into TweenService, you can do something like this (explained in this post):

local RunService = game:GetService"RunService"
local Heartbeat = RunService.Heartbeat
local Goal = CFrame.new(...)
local Starting = Part.CFrame
local TimeToTake = 100/60
local Accumulated = 0
while TimeToTake > Accumulated do
	Accumulated += Heartbeat:Wait()
	Part.CFrame = Starting:Lerp(Goal,math.min(Accumulated/TimeToTake,1))
end

Resources
TweenService
TweenService:Create()
TweenService:SmoothDamp()

Let me or someone else know if you have any other questions and we’ll try and answer them as best we can. Hope this helps! :grin:

1 Like