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

how to tween a part to move to another part ?

Asked by 3 years ago

Idk how to say this but i want to make a part move smoothly until it touches another part

2 answers

Log in to vote
1
Answered by 3 years ago

For more info you can look up a more in-depth tutorial or look here. This is the basic script:

local TweenService = game:GetService("TweenService")

local part = Instance.new("Part")

local goal = {} -- Stuff you want the part to do
goal.Color = Color3.new(0, 1, 0)

local tweenInfo = TweenInfo.new(
    2, -- Time the tween takes
    Enum.EasingStyle.Linear, -- EasingStyle
    Enum.EasingDirection.Out, -- EasingDirection
    -1, -- RepeatCount (infinite loop when less than 0)
    true, -- Reverses (tween will reverse once reaching it's goal)
    0 -- DelayTime
)

local tween = TweenService:Create(part, tweenInfo, goal) 
--^Part you want to tween, tweeninfo, goal

tween:Play()
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

For the third parameter of TweenService:Create(), you can set the Position to the Position of the part. For example

game:GetService("TweenService"):Create(game.Workspace.Part, TweenInfo.new(5, Enum.EasingStyle.Linear, EnumEasingDirection.InOut, 0, false, 0), {Position = game.Workspace.OtherPart.Position}):Play()

Answer this question