> [!CAUTION]
> knowledge needed: tables, variables, services, RBXScriptSignals, etc
# TweenService
Tweenservice is used to smoothly transition properties of a instance, for example you could change a parts transparency from 0 -> 1 over the course of 4 seconds.
## Creating Tweens
To create a tween you need to get the `TweenService` object and use the `:Create()` method.
```lua
local TweenService = game:GetService("TweenService")
local Tween = TweenService:Create(Instance, TweenInfo, PropertyTable)
```
### TweenInfo
TweenInfo is a set of parameters for your tween that will tell it things like how long its supposed to take, if its gonna reverse or repeat, etc
To create a TweenInfo you can use `TweenInfo.new()`
**TweenInfo API**
```lua
local Info = TweenInfo.new(
time: number?,
easingStyle: Enum.EasingStyle?,
easingDirection: Enum.EasingDirection?,
repeatCount: number?,
reverses: boolean?,
delayTime: number?
)
```
### PropertyTable
A tweens PropertyTable is just a table that represents what the tween is supposed to be changing.
```lua
local PropertyTable = {
Transparency = 1,
Size = Vector3.new(10,10,10)
}
```
### Created Tween Example
```lua
local TweenService = game:GetService("TweenService")
local Part = Instance.new("Part")
Part.Parent = workspace
local Info = TweenInfo.new(
2, -- time
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0, -- repeat count
true, -- reverses
0 -- delay
)
local PropertyTable = {
Transparency = 1,
Size = Vector3.new(10,10,10)
}
local Tween = TweenService:Create(Part, Info, PropertyTable)
```
## Working With Created Tweens
### Methods
Tweens have 3 different methods you can use on them, Most are pretty self explanatory on what they do.
- :Play()<br>
- :Pause()<br>
- :Cancel()<br>
### Events
Tweens have different events that will fire upon certain things happening in the tweens playback. at the current time there is only 1 event.
- .Completed<br>
Fires upon the tween finishing its playback.
## Finished Product
```lua
local TweenService = game:GetService("TweenService")
local Part = Instance.new("Part")
Part.Parent = workspace
local Info = TweenInfo.new(
2, -- time
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0, -- repeat count
true, -- reverses
0 -- delay
)
local PropertyTable = {
Transparency = 1,
Size = Vector3.new(10,10,10)
}
local Tween = TweenService:Create(Part, Info, PropertyTable)
Tween.Completed:Connect(function()
print("Tween Completed")
end)
Tween:Play()
```