I have tried using many methods like while true loops and so on and noone seemed to be successful.
Current Code:
local gui = script.Parent
local PressStartText = gui.PressStartText
local tweenservice = game:GetService("TweenService")
local Tween_Info = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local function AnimateText(InstanceToAnimate, tweenInfo, PropertyToAnimate)
while true do
tweenservice:Create(InstanceToAnimate, tweenInfo, {Position = UDim2.new(0.5, 0, 0.6, 0)}):Play()
wait(2)
tweenservice:Create(InstanceToAnimate, tweenInfo, {Position = UDim2.new(0.5, 0, 0.8, 0)}):Play()
end
end
AnimateText(PressStartText, Tween_Info)
I’m confused as to what you’re trying to do, you’ve posted a script with a looped tween but not actually given us a description of what you want other than an Up and Down motion, maybe it’s just me? Have you got an example?
i don’t exactly know what you are trying to achieve, but as of my guess it is a tween that plays and reverts in a loop.
you can use this:
local tween_service = game:GetService("TweenService")
local ti = Tweeninfo.new(time,easingstyle,easingdirection,math.huge --[[repeat count]],true --reverses the tween if true)
local goal = {}
ts:Create(instance,ti,goal)
local gui = script.Parent
local PressStartText = gui.PressStartText
local tweenservice = game:GetService("TweenService")
local Tween_Info = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local function AnimateText(InstanceToAnimate, tweenInfo, PropertyToAnimate)
while true do
local Tween1 = tweenservice:Create(InstanceToAnimate, tweenInfo, {Position = UDim2.new(0.5, 0, 0.6, 0)})
Tween1:Play()
Tween1.Completed:Wait()
local Tween2 = tweenservice:Create(InstanceToAnimate, tweenInfo, {Position = UDim2.new(0.5, 0, 0.8, 0)})
Tween2:Play()
Tween2.Completed:Wait()
end
end
AnimateText(PressStartText, Tween_Info)
If you are going to reuse the function you can wrap it in a task.spawn, though this is extremely inefficient especially when TweenService provides you with both a looping capability and an ability to reverse the tween.
local gui = script.Parent
local PressStartText = gui.PressStartText
local tweenservice = game:GetService("TweenService")
local Tween_Info = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local function AnimateText(InstanceToAnimate, tweenInfo, PropertyToAnimate)
task.spawn(function()
while true do
local Tween1 = tweenservice:Create(InstanceToAnimate, tweenInfo, {Position = UDim2.new(0.5, 0, 0.6, 0)})
Tween1:Play()
Tween1.Completed:Wait()
local Tween2 = tweenservice:Create(InstanceToAnimate, tweenInfo, {Position = UDim2.new(0.5, 0, 0.8, 0)})
Tween2:Play()
Tween2.Completed:Wait()
end
end)
end
AnimateText(PressStartText, Tween_Info)
local gui = script.Parent
local PressStartText = gui.PressStartText
local function AnimateText(InstanceToAnimate, tweenInfo, PropertyToAnimate)
InstanceToAnimate:TweenPosition(
UDim2.new(0.5, 0, 0.6, 0),
Enum.EasingDirection.Out,
"Quad",
2,
true,
function(state)
InstanceToAnimate:TweenPosition(
UDim2.new(0.5, 0, 0.6, 0),
Enum.EasingDirection.Out,
"Quad",
2,
true,
)
end
)
end
while true do
AnimateText(PressStartText, Tween_Info)
end