This mini-lesson on TweenService in Roblox Studio.
-
Create a part
-
in the Explorer, select the created part and add a script to it
3.Code:
1.adding a service to the game
--/Service/ --/it is not necessary to write it, since it is a designation/
local TweenService = game:GetService("TweenService")
2, we create a link to the part
--/Links/
local part = game.Workspace.Part --/link to a part (or to another object)/
3.Now we are writing a TweenInfo data type that stores parameters for TweenService:Create() to specify the animation behavior.
local Info = TweenInfo.new(1) --/The TweenInfo data type stores parameters for TweenService:Create() to specify the behavior of the tween/
4.Now we create a Target variable and create the size of the future part in it. (or other parameters that are specified in the Part)
local Target = {Size = Vector3.new(15,15,15)} --/choosing the size of the part, What would you like it to become --/in addition to size, you can choose other parameters that are in the part (Color, Transparency, Material, and so on)
5.Create a variable and list all the variables (Part, Info, Target) (Part is a part that will take dimensions. Info is a variable that will repeat the size animation if TweenInfo.new(1) is specified, then it will be once if TweenInfo.new(2), then it will show the Size animation twice. Target is the specified size that will be part.
local Tween = TweenService:Create(part, Info, Target) --/enumerations of all variables/
6.We write wait(10). Wait is the waiting time. If wait(10) then waits 10 seconds, if wait(5) then 5 seconds.
wait(10) --/Waiting time(the time can be whatever you want)/
7.the Tween variable lists other variables and using :Play(), the Tween variable triggers other variables that are listed in the Tween variable
Tween:Play() --/Starts the Tween variable/
Full Code:
--/Service/
local TweenService = game:GetService("TweenService") --/TweenService adding/
--/Links/
local part = game.Workspace.Part --/link to a part (or to another object)/
local Info = TweenInfo.new(1) --/The TweenInfo data type stores parameters for TweenService:Create() to specify the behavior of the tween/
local Target = {Size = Vector3.new(15,15,15)} --/choosing the size of the part, What would you like it to become --/in addition to size, you can choose other parameters that are in the part (Color, Transparency, Material, and so on)
local Tween = TweenService:Create(part, Info, Target) --/enumerations of all variables/
wait(10) --/Waiting time(the time can be whatever you want)/
Tween:Play() --/Starts the Tween variable/
Thank you so much for reading this topic!