local ts = game:GetService("TweenService")
local part = script.Parent
local repeatdo = 0
local Info = TweenInfo.new(10,Enum.EasingStyle.Sine,Enum.EasingDirection.In,1231312213312321331231231312321313123,true,10)
local goals = {
Position = Vector3.new(242.885, -573.734, -917.707);
}
local tweenTrack = ts:Create(part,Info,goals)
tweenTrack:Play()
I want to add a delay time for when it reaches the destination, I want it to wait for a few seconds before reversing.
I do not want new code, I just want my code but with the new improvements.
Oh wait I think I get it. Delay time in the tween info is only for the delay before it starts, so if you want to make a delay, consider this code:
local ts = game:GetService("TweenService")
local part = script.Parent
local waitTime = 10 --set your wait time here
local Info = TweenInfo.new(10,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
local tweenTrack = ts:Create(part,Info,{Position = Vector3.new(242.885, -573.734, -917.707)})
local tweenTrack2 = ts:Create(part,Info,{Position = part.Position})
tweenTrack.Completed:Connect(function()
task.wait(waitTime)
tweenTrack2:Play()
end)
tweenTrack2.Completed:Connect(function()
task.wait(waitTime)
tweenTrack:Play()
end)
tweenTrack:Play()
If it worked, please set it as the new solution so others can see it too
local ts = game:GetService("TweenService")
local part = script.Parent
local waitTime = 10 --set your wait time here
local Info = TweenInfo.new(10,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
local tweenTrack = ts:Create(part,Info,{Position = Vector3.new(242.885, -573.734, -917.707)})
local tweenTrack2 = ts:Create(part,Info,{Position = Vector3.new(part.Position.X,part.Position.Y,part.Position.Z})
tweenTrack.Completed:Connect(function()
task.wait(waitTime)
tweenTrack2:Play()
end)
tweenTrack2.Completed:Connect(function()
task.wait(waitTime)
tweenTrack:Play()
end)
tweenTrack:Play()
What’s wrong with the train in the video? I thought you wanted a part to move to a position, wait, then return toi ts original position, wait again, and repeat. That’s what the code I gave you does. If that is not what you’re trying to achieve, then what is?
Edit: You can adjust the waitTime variable to change how long the tween waits before repeating again. In the code I posted, it was set to ten seconds and I could see that the video you sent wasn’t even ten seconds long. Either wait for ten seconds to see if it works or just reduce it to something like one second.
Edit2: I just realized when testing out the code that a parenthesis was missing ;-; you should have noticed it in the output dude. Here’s the new code:
local ts = game:GetService("TweenService")
local part = script.Parent
local waitTime = 1 --set your wait time here
local Info = TweenInfo.new(10,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
local tweenTrack = ts:Create(part,Info,{Position = Vector3.new(447, 0.5, 3965)})
local tweenTrack2 = ts:Create(part,Info,{Position = Vector3.new(part.Position.X,part.Position.Y,part.Position.Z)})
tweenTrack.Completed:Connect(function()
task.wait(waitTime)
tweenTrack2:Play()
end)
tweenTrack2.Completed:Connect(function()
task.wait(waitTime)
tweenTrack:Play()
end)
tweenTrack:Play()
It Honestly seems like a Waste of time to wait for a Tween to Finish using Completed just to fire another Tween, when you can just have one Tween, and a Parameter do it for you.
He tried it but it didn’t work, because the delay is only for the start of the tween and not between the repetition of the tween. He wants a delay both at the start and when it is about to repeat.