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()
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.
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)}
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.