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

How To Tween A Part On The Y Axis?

Asked by 5 years ago

I have a tween function script and I am looking to use it as a platform moving upward. How do I change the axis of which it moves?

platform = script.Parent

local TweenService = game:GetService("TweenService")

local TweenInfo = TweenInfo.new(3,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)

local platformMove = {CFrame = platform.CFrame + platform.CFrame.lookVector * 8}

local openFunction = TweenService:Create(platform,TweenInfo,platformMove)

openFunction:Play()

3 answers

Log in to vote
0
Answered by 5 years ago

Sorry I'm on my phone right now, so I can't structure this answer properly, but

There exists an upVector ** and a **rightVector, in your case you want the platform to go along its upVector instead of the lookVector.

Please look on the roblox wiki for more info, as I can't provide a link currently.

Ad
Log in to vote
0
Answered by
yyyyyy09 246 Moderation Voter
5 years ago
Edited 5 years ago

You would want to use addition with a vector 3 this will probably explain it better than I will.

http://wiki.roblox.com/index.php?title=CFrame#CFrame_.2B_Vector3

local platformMove = {CFrame = platform.CFrame + Vector3.new(0,8,0)}

Log in to vote
0
Answered by 5 years ago

what you could do is group that part (its fine if its bye itself) then insert a script into that group (not in the part). then what the script could look like is;

local TweenService = game:GetService("TweenService")
local platform =  script.Parent:WaitForChild("Platform")
local tweeningInformation = TweenInfo.new(

    0.5 -- this is the time it takes for the part to get from one point to the other
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0, -- how many times you want the tween to repeat
    false, -- do you want it to be repeated?
    0 -- delay in seconds between each tween

)

local platformMove = {CFrame = CFrame.new(0,0,0)} -- change the "0,0,0" to the position you want the tween to go.
local platformBack = {CFrame = Cframe.new(0,0,0)} -- change "0,0,0" to the original starting point of the platform, if you don't want to move it back, delete this.
local tween1start = TwennService:Create(platform, tweeningInformation, platformMove)
local tween1back = TwennService:Create(platform, tweeningInformation, platformBack)

tween1start:Play()
wait(2) -- after the first tween has ended, how long do you want to wait until the 2nd one starts?
tween1back:Play()

the script above is not tested, please let me know if you run into any errors, make sure to place it in a normal script inside of the group.

0
might have made it a bit over complicated, but this is how i do it. cruizer_snowman 117 — 5y

Answer this question