TweenService Help

Hey guys,

the docs on tween service are a bit advanced in terms of language for me. So can anyone please tell me How Tween Service works?

Let’s see what you would use TweenService to tween.

for example

  • Moves frame’s position to X: 1 | Y: 1
local TweenService = game:GetService("TweenService")
TweenService:Create(
	script.Parent.Frame,  -- Instance
	TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut),  -- Tween Info
	{Position = UDim2.fromScale(1, 1)} -- Property
):Play()
  • Moves baseplate to Target position
local TweenService = game:GetService("TweenService")
TweenService:Create(
	workspace.Baseplate,  -- Instance
	TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut),  -- Tween Info
	{Position = Vector3.new(1, 1, 1)} -- Property
):Play()
  • Change baseplate color to the target Color3
local TweenService = game:GetService("TweenService")
TweenService:Create(
	workspace.Baseplate,  -- Instance
	TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut),  -- Tween Info
	{Color = Color3.fromRGB(255, 255, 255)} -- Property
):Play()
  • You can also wait for the tween to complete before continuing by doing this
local TweenService = game:GetService("TweenService")
local Tween = TweenService:Create(
	workspace.Baseplate,  -- Instance
	TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut),  -- Tween Info
	{Color = Color3.fromRGB(255, 255, 255)} -- Property
)
Tween:Play()
Tween.Completed:Wait()

print("Completed")

These 2 lines confuse me. What is TweenInfo.new? What is Enum, and Easing Style, and Sine, literally everything in this line I do not understand, and the second one.

TweenInfo.new() is a data to tell how the tween should play. Reference: TweenInfo | Documentation - Roblox Creator Hub

--       Play time, EasingStyle, EasingDirection
TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

Does the picture show all ways a Tween Plays?

Yes, the picture above shows how EasingStyle plays.

How does each of them work in the Tweening of something.


So this is the create method of TweenService
It takes an instance, a tweeninfo, and a table with properties.
What it does is it will animate properties of the provided instance from their current value to the value in the table.
The tween info will give information of how to do that. The easing style will change how the property is moved.

it’s like FadeIn/FadeOut effect, or it’s like smoothing out the animation.

So If I wanted a moving platform to bounce off, would I use Bounce?

I understand that, but how can one make it? I don’t properly understand how to make it.

Like platform reaches its target position and bounce as if it hit the wall? Then yeah.

yep.

This entitles character limit.

It’s best if you take the sample code and play around with the EasingStyle and find out at playtime.

Can I add Instance.New and create a new part at the start?

TweenInfo.new takes these arguements


for example:

local tweenInfo = TweenInfo.new(
	3.2, -- time
	Enum.EasingStyle.Sine, -- easing style
	Enum.EasingDirection.InOut, -- easing direction
	nil, -- repeat count
	false, -- reverses
	nil -- delay time
)

Then you can use that in your tween:create:

local TweenService = game:GetService("TweenService")
local tween = TweenService:Create(
	workspace.Part,
	tweenInfo,
	{
		CFrame = CFrame.new(0,30,0) * CFrame.Angles(0,math.pi,0),
		Color3 = Color3.fromRGB(255, 170, 0)
	}
)

Finally, to play the tween you call tween:Play()

tween:Play()

uhh if you mean creating new part before running the tween on that part, yes.

Your format/organization is different from @UntileKakka’s format/organization.

Yeah if you want a fireball to move, then in a server script you create a part, or most people just clone a premade part from ReplicatedStorage. Then you place it in workspace and tween it. Then I usually use Debris to delete it after it is done.

Well, I’m just giving a break down and trying to explain in a simple way possible. hkep is giving you more realistic answer of how it works.