How to make it so, when my moving part reaches a final point and goes up after time?

I have a moving part that is basically an elevator

local part = script.Parent
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
	600, --Duration in seconds
	Enum.EasingStyle.Linear, --EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	true, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime in seconds
)
local tweenGoal = {Position = part.Position + Vector3.new(0,-1000,0)}
local tween = tweenService:Create(part,tweenInfo,tweenGoal)
tween:Play()

this makes the part go down for 30 floors, i want it so when it hits the final position, it waits for 30 seconds and the part goes up.

in the TweenInfo, you need to change the last number (0), to 30

2 Likes

When i do that, elevator stops moving at all

local part = script.Parent
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
	600, --Duration in seconds
	Enum.EasingStyle.Linear, --EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	true, -- Reverses (tween will reverse once reaching it's goal)
	30 -- DelayTime in seconds
)
local tweenGoal = {Position = part.Position + Vector3.new(0,-1000,0)}
local tween = tweenService:Create(part,tweenInfo,tweenGoal)
tween:Play()

It should be exactly this.

Yea, that worked, thank you. Do you know how do i make so it goes up way more faster after it reaches the end and the time goes?

local part = script.Parent
local tweenService = game:GetService("TweenService")
local tweenInfoDown = TweenInfo.new(
	600, --Duration in seconds
	Enum.EasingStyle.Linear, --EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	0, -- RepeatCount (when less than zero the tween will loop indefinitely)
	false, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime in seconds
)
local tweenInfoUp = TweenInfo.new(
	60 , --Duration in seconds
	Enum.EasingStyle.Linear, --EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	0, -- RepeatCount (when less than zero the tween will loop indefinitely)
	false, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime in seconds
)
local tweenGoalDown = {Position = part.Position + Vector3.new(0,-1000,0)}
local tweenGoalUp = {Position = part.Position + Vector3.new(0,1000,0)}

local tweenDown = tweenService:Create(part,tweenInfoDown,tweenGoalDown)
local tweenUp = tweenService:Create(part,tweenInfoUp,tweenGoalUp)

tweenDown:Play()
tweenDown.Completed:Connect(function()wait(30)tweenUp:Play()end)
tweenUp.Completed:Connect(function()wait(30)tweenDown:Play()end)
 

Tell me if this worked, I basically made another tween for it going up and made it play when its done going down, then when its done going up, it goes down again.

1 Like

Wow, thank you very much, that worked…

1 Like