Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to tween a part to move to another part ?

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

2 answers

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()

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()

This discussion is preserved as it was. New answers, comments, and votes are closed.