TheHeckingDeveloper

TweenPartDemo

Jul 16th, 2021
698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. -- Services
  2. local TweenService = game:GetService("TweenService")
  3.  
  4. -- The first parameter of TweenService:Create is the instance we want to tween,
  5. -- in this case the part, so let's create a variable for it
  6. local part = script.Parent
  7.  
  8. -- The second parameter is TweenInfo. This is a datatype created in a similar
  9. -- way to Vector3s, using TweenInfo.new.
  10.  
  11. local info = TweenInfo.new(
  12.     1, -- The time we want the tween to last
  13.     Enum.EasingStyle.Linear, -- The style we want the tween to play in
  14.     Enum.EasingDirection.InOut,-- I don't know how to describe this
  15.     4, -- The amount of times we want the tween to repeat
  16.     true, -- Whether we want the tween to reverse when it's done playing or not
  17.     0.4 -- The delay time in between each repetition of the tween
  18. )
  19.  
  20. -- The third parameter would be the properties that you want to change, and the
  21. -- values you want them to be at by the end of the tween
  22.  
  23. local properties = {
  24.     Color = Color3.new(1, 0, 0)
  25. }
  26.  
  27. -- Now, we will call TweenService:Create, and it will return (give back) a Tween object
  28. local tween = TweenService:Create(
  29.     part,
  30.     info,
  31.     properties
  32. )
  33.  
  34. -- Hold on! The tween isn't playing just yet. We need to call tween:Play to make it run.
  35. tween:Play()
Advertisement
Add Comment
Please, Sign In to add comment