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

How can I improve the tweenservice() script?

Asked by
xsodar 19
4 years ago

Hello, anyone know how to use 1 tweenservice() several times? Let me explain:

01local mP = script.Parent
02 
03local tweenService = game:GetService("TweenService")
04 
05local mpInfo = TweenInfo.new(
06    15,
07    Enum.EasingStyle.Quad,
08    Enum.EasingDirection.InOut,
09    0,
10    false,
11    0
12)
13 
14local mpInfoUp = TweenInfo.new(
15    5,
View all 60 lines...

I want it to repeat the same animation but not return to the position it had at first. Because if I do as I have done in the script right now, it will work but it will take too much time and become a real mess.

Is it possible to use something else than Position = Vector3.new()? Because if I would put the part that has the animation somewhere else it will always come back to that position. I want to be able to put it anywhere on my map without changing the script all the time I change the position of the part.

Thanks for the help, Xsodar

1 answer

Log in to vote
1
Answered by 4 years ago

You can create a function with position as input to play a tween animation on a specific object.

My take:

01local tweenService = game:GetService("TweenService")
02local mP = script.Parent
03 
04local mpInfo = TweenInfo.new(15,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0,false,0)
05 
06local mpInfoUp = TweenInfo.new(5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
07 
08local mpTween = function(position)
09    local Tween = tweenService:Create(mP,mpInfo,{Position = position})
10    Tween:Play()
11end
12 
13local mpTweenUP = function(position)
14    local Tween = tweenService:Create(mP,mpInfoUp,{Position = position})
15    Tween:Play()
View all 34 lines...
Ad

Answer this question