Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can someone explain tweening with parts to me in a clear way?

Asked by 5 years ago

I am just having trouble understanding how it works(I'm talking about how wiki ect explains it, maybe im just reading the wrong wiki). I am fine when it comes to gui. But for parts I figured it would be better to tween instead of use loops.

1 answer

Log in to vote
0
Answered by 5 years ago

Tweening is the process of smoothly making any numerical property transition from it initial state towards another, to start get the tweenservice

local TweenService = game:GetService("TweenService")

then lets look at how to make a tween:

local Tween = TweenService:Create(...)

we will replace the dots with three values, the part (or any instance really), the tweeninfo (a value containing information about how the tween plays and looks), and the dictionary (a table containing propertys that the tween will make the instance transition to)

1: The part (or instance), this is should be obvious, 2: The tweeninfo, its a special roblox exclusive data type like Vector3 or Faces:

tweeninfo.new(
    how many seconds the tween takes to complete (1 = default),
    an EasingStyle enum (Enum.EasingStyle.Quad = default),
    an EasingDirection enum (Enum.EasingDirection.Out = default),
    how many times to repeat (0 = default),
    will it reverse each time (false = default),
    the delay until the tween starts (0 = default)
)

and examples of different easingstyles (and directions) here: https://developer.roblox.com/assets/5ad23898c052d5f20b766854/Easingstyle.gif

3: the dictionary, this is a table with properties of what the new properties will be, example:

{
    Size = Vector3.new(1,5,2),
    ["CFrame"] = CFrame.new(1,1,99),
    Transparency = 0.7,
    Massless = true,
    Color3 = Color3.new(1,1,1)
}

so now with all of the examples we can make a tween

local Info = tweeninfo.new(
    1,
    Enum.EasingStyle.Linear
    --everything in a tweeninfo is optional
)
local Dict = {
    Size = Vector3.new(1,5,2),
    ["CFrame"] = CFrame.new(1,1,99),
    Transparency = 0.7,
    Massless = true,
    Color3 = Color3.new(1,1,1)
}
local Tween = TweenService:Create(script.Parent.Part, Info, Dict)
Tween:Play()

we can also stop a tween

Tween:Stop

documentation of the tween object is here:

https://developer.roblox.com/api-reference/class/Tween

0
Question where would I put the CFrame it moves too? Like for example if I was making a sliding door(Which im not) XX_Doggoa 24 — 5y
0
(sorry for 6 day late reply) make the cframe in the dictionary, it would probably be best to calculate a relative position fanofpixels 718 — 5y
Ad

Answer this question