Background
Okay, that may have been very hard to understand, allow me to reiterate.
So I have a bundle of parts that are all anchored, in a specific group. I am currently iterating through them all in a for
loop. There are no problems with the loop or anything, just my code that I actually use to move it.
I am using TweenService to smoothly move these parts. If it helps, I am using the method of creating a TweenInfo, creating a Tween, and then playing it at a select time.
The Problem
The issue starts to occur with the third argument of my Tween. I put in the instance to tween, the information used to tween, and for my table, the target CFrame of the part. The only problem, is that how do I go about moving it upwards by 100 studs, while it is rotated? Do I use CFrame? Should I multiply or equal it? And most importantly, how can I move it on the global Y-Axis, no matter it's rotation? Also, I know that this probably has something to do with :ToGlobalAxis()
(or whatever the function is), but I don't know how to use it.
My Code
local tweenService = game:GetService("TweenService") local train = script.Parent local cars = train.Modeling:GetChildren() local tweenInformation = TweenInfo.new( 10, Enum.EasingStyle.Circular, Enum.EasingDirection.In, 0, false, 0 ) for i,v in next,cars do for x,y in next,v:GetChildren() do tweenService:Create(y,tweenInformation,{CFrame = CFrame.new(0,100,0)}):Play() -- Only moves it on the part's Y-Axis, not the global Y-Axis. end end
Any help would be appreciated!
If you want to tween a model then you have to weld every part of the model to the primary part of the model and then u tween the primarypart not tween every part of a model. and if you want to just move a part 100 studs higher then ur fine with Position (which is a Vector3)
Example in this case
local tweenService = game:GetService("TweenService") local train = script.Parent local cars = train.Modeling:GetChildren() -- each car his parts are welded to the primary part, local tweenInformation = TweenInfo.new( 10, Enum.EasingStyle.Circular, Enum.EasingDirection.In, 0, false, 0 ) for _, car in pairs(cars) do -- car is a model with a PrimaryPart tweenService:Create(car.PrimaryPart,tweenInformation,{Position = car.PrimaryPart.Position + Vector3.new(0,100,0)}):Play() -- using the old position i can make every car go 100 studs higher on Y than its previous position end
btw there are plugins for welding each part in a model to another part
If these are just random parts inside each other than you can do
local tweenService = game:GetService("TweenService") local train = script.Parent local cars = train.Modeling:GetChildren() local tweenInformation = TweenInfo.new( 10, Enum.EasingStyle.Circular, Enum.EasingDirection.In, 0, false, 0 ) for i,v in next,cars do for x,y in next,v:GetChildren() do tweenService:Create(y,tweenInformation,{Position = y.Position + Vector3.new(0,100,0)}):Play() -- moves the part 100 studs higher on the Y axis end end