tech/game

21/08/06 How to Use Tweens and TweenService - Roblox Studio Tutorial

tech-lover 2021. 8. 6. 13:28

https://youtu.be/bcMZmwZGK-o

- Transparency

```

local part = script.Parent

local TweenService = game:GetService("TweenService")

 

local tweenInfo = TweenInfo.new(

    5--Time

    Enum.EasingStyle.Linear--Easing Style

    Enum.EasingDirection.Out--EasingDirection

    -1--Repeat Count

    true--Reverse

    0 --DelayTime

)

 

local tween = TweenService:Create(part, tweenInfo, {Transparency = 1})

tween:Play()

```

 

- Color

```

local part = script.Parent

local TweenService = game:GetService("TweenService")

 

local tweenInfo = TweenInfo.new(

    5--Time

    Enum.EasingStyle.Linear--Easing Style

    Enum.EasingDirection.Out--EasingDirection

    -1--Repeat Count

    true--Reverse

    0 --DelayTime

)

 

local tween = TweenService:Create(part, tweenInfo, {Color = Color3.fromRGB(00255)})

tween:Play()

```

 

- Size

```

local part = script.Parent

local TweenService = game:GetService("TweenService")

 

local tweenInfo = TweenInfo.new(

    5--Time

    Enum.EasingStyle.Linear--Easing Style

    Enum.EasingDirection.Out--EasingDirection

    -1--Repeat Count

    true--Reverse

    0 --DelayTime

)

 

local tween = TweenService:Create(part, tweenInfo, {Size = Vector3.new(8,8,8)})

tween:Play()

```

 

- Orientation

```

local part = script.Parent

local TweenService = game:GetService("TweenService")

 

local tweenInfo = TweenInfo.new(

    5--Time

    Enum.EasingStyle.Linear--Easing Style

    Enum.EasingDirection.Out--EasingDirection

    -1--Repeat Count

    false--Reverse

    0 --DelayTime

)

 

local tween = TweenService:Create(part, tweenInfo, {Orientation = Vector3.new(0,180,0)})

tween:Play()

```

 

- Moving Position to Target (2D)

```

local part = script.Parent

local TweenService = game:GetService("TweenService")

 

local tweenInfo = TweenInfo.new(

    5--Time

    Enum.EasingStyle.Linear--Easing Style

    Enum.EasingDirection.Out--EasingDirection

    -1--Repeat Count

    true--Reverse

    0 --DelayTime

)

 

local tween = TweenService:Create(part, tweenInfo, {Position = part.Parent.Target_2D.Position})

tween:Play()

```

 

- Moving Position to Target (3D)

```

local part = script.Parent

local TweenService = game:GetService("TweenService")

 

local tweenInfo = TweenInfo.new(

    3--Time

    Enum.EasingStyle.Linear--Easing Style

    Enum.EasingDirection.Out--EasingDirection

    -1--Repeat Count

    false--Reverse

    0 --DelayTime

)

 

local tween = TweenService:Create(part, tweenInfo, {Position = part.Parent.Target_3D.Position})

tween:Play()

```