CFrame Animations

Hey, I’m trying to get this method to work to animate the taking out and putting back of an aircraft service trolley. I’m using Motors rather than the primarypart due to how it operates inside of a PlaneKit, Using Motor6Ds is the only way that works with this particular planekit, stable that is without the risk of glitching the A/C.

The CFrame animation works when I active the ProximityPrompt, however it just keeps going instead of stopping. Any ideas on what I’m doing wrong?

ServerScript (TrolleyHandler)

local function TakeTrolleyAnim()
	repeat wait(0.00001) Motor.C1 = Motor.C1 *,0,0.05) until Motor.C1 ==,0,0.10)



… You should use a TweenService instead.

Not only is the TweenService useful for CFrame situations, like this, but it has a parameter that allows it to go for as long as you want it to.

Example using your code.

local TweenService = game:GetService("TweenService")
local TrolleyTweenInfo =

local function TakeTrolleyAnim()
	-- repeat wait(0.00001) Motor.C1 = Motor.C1 *,0,0.05) until Motor.C1 ==,0,0.10) <-- this is unnecessary, since again TweenService exists. you'd be doing more work for yourself doing it this way.
	local TrolleyTween = TweenService:Create(Motor, TrolleyTweenInfo, {C1 =, 0, 0.10)})

If you would like to know what is going on for each line…

  1. local TrolleyTweenInfo =

A TweenInfo is probably self-explanatory, but it allows you to control how long the Tween should play out. And also, control how it moves.

Here’s what parameters you could use for a TweenInfo:

local toofoo =
	3, -- the time it takes for the tween to finish

	Enum.EasingStyle.Quad, --[[ the type of motion it does during the tween. 
								you should read more of that here:]]

	Enum.EasingDirection.InOut, --[[ the ease it uses to do that. 
									if "In", then it'll be like a car building up speed.
									if "Out", then it'll be like a car breaking; it slows down after you hold on the breaks for so long.
									"InOut" is just the combination of both.]]

	-1, --[[ this is how many times it'll repeat the tween. 
			-1 is to infinitely loop it, which means it will never finish.]]

	true, --[[ this is for the tween to reverse after it reaches it's endpoint.
			if true, it'll reverse]]

	2 -- the delay time of the tween. (before it starts)
There's two images that allows you to see how each Enum.EasingStyle operate.


  1. local TrolleyTween = TweenService:Create(Motor, TrolleyTweenInfo, {C1 =, 0, 0.10)})

This returns a Tween, that can be use to play, stop or pause the tween (that’s probably obvious).

Creating a Tween with TweenService:Create requires the Instance You want to be tweened, a TweenInfo and the parameters that it should modify/change to as a table. To declare them, it’s just like getting the property of anything else.

The reason the declared instance’s (first variable in TweenService:Create) properties is in a table is, so that, you can have it change multiple values within the same tween.

-- {C1 =, 0, 0.10)} is just the same as..
Motor.C1 =, 0, 0.10)

-- {Position =, 103, 284), Size =, 7, 6)} is just the same as..
Part.Position =, 103, 284)
Part.Size =, 7, 6)
This is the type of objects that can be tweened.
  • number
  • bool
  • CFrame
  • Rect
  • Color3
  • UDim
  • UDim2
  • Vector2
  • Vector2int16
  • Vector3

Now, this should help you make your trolley without having to cause a headache for yourself! If anything else happens that you’re not sure of, you can PM me; Otherwise, happy coding and enjoy your day!

1 Like

Tweens are really nice for stuff like this as Withurlo mentioned above. However, if you would like to carry on moving the part by changing it’s CFrame then I’ve got a little solution.

If you know your target co-ordinate then instead of using the motor’s CFrame you can check for it’s position.

For example, below is me moving a part using the same CFrame technique until it’s z co-ordinate is 10 or above.

local part = script.Parent
repeat wait(0.00001) part.CFrame = part.CFrame *,0,0.05) until part.Position.Z >= 10

I’d personally recommend using tweens though, since you can re-use them a lot easier and can animate them to accelerate more realistically.
With the tween code that Withurlo wrote above, the trolley should move to the desired location no matter where it starts from.

1 Like