# TweenService（ロブロックス クラス）

> パーツの位置・色・透明度などを、なめらかに少しずつ変化させる（アニメーションさせる）サービスです。

- URL：https://roblox.minecraft-okinawa.com/reference/classes/TweenService/
- 公式：https://create.roblox.com/docs/reference/engine/classes/TweenService
- 受け継いでいるクラス：Instance

## 使用例：行ったり来たりする床

（Script／置く場所：動かしたいパーツの中）

```lua
local TweenService = game:GetService("TweenService")
local platform = script.Parent :: BasePart
platform.Anchored = true

local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true)
local goal = { Position = platform.Position + Vector3.new(0, 0, 20) }
local tween = TweenService:Create(platform, tweenInfo, goal)
tween:Play()
```

## メソッド

- `TweenService:Create(instance: Instance, tweenInfo: TweenInfo, propertyTable: Dictionary): Tween`：変化させるインスタンス・変化のしかた（TweenInfo）・目標の値を指定して、Tweenを作ります。作ったTweenはPlayで動き出します。
- `TweenService:GetValue(alpha: float, easingStyle: EasingStyle, easingDirection: EasingDirection): float`：Calculates a new alpha given an EasingStyle and EasingDirection.
- `TweenService:SmoothDamp(current: Variant, target: Variant, velocity: Variant, smoothTime: float, maxSpeed: float?, dt: float?): Tuple`：Smoothly interpolates a value towards a target, simulating a critically damped spring.

英語の説明とメンバー一覧：Roblox Creator Documentation（CC BY 4.0）。日本語の解説はこのサイト独自のものです。

執筆：鈴木孝昌（現役プロジェクトマネージャー／プログラミング講師）／運営：沖縄マイクラ部 プログラミングスクール「クロスウェーブ」（https://minecraft-okinawa.com/）