How do I animate a part? (That is not an NPC)

Hello,
Just wondering how do I animate a part?
Thanks,
Sasial.

1 Like

Try Tweening or CFraming

CFrame:
https://developer.roblox.com/api-reference/datatype/CFrame

Tweening:
https://developer.roblox.com/api-reference/class/Tween

1 Like

You cannot animate anything that doesn’t have humanoid.

Lies…

2 Likes

Assuming you already have the part rigged, you can use an animation controller to load animations onto a model.

https://developer.roblox.com/api-reference/class/AnimationController

1 Like

Ohh, sorry my bad didn’t knew.

1 Like

Thanks for such a fast reply. How do you rig a part?

Use this plugin image

I understand that you can play animations with it but how can you create animations with it?
Example of what I mean: https://www.youtube.com/watch?time_continue=2&v=C5TkF1hqjDM

I use TweenService a lot when animation objects. You should try out using TweenService.

Here’s a resource on the Roblox Developer website that’ll help you

I just realized that if you search up “TweenService” on the website, there’s a header above it that says “ANIMATIONS”

Example use:

local ts=game:GetService('TweenService')
local part=Instance.new('Part',workspace) part.Anchored=true
local tween1=ts:Create(part,TweenInfo.new(2.5,Enum.EasingStyle.Elastic,Enum.EasingDirection.InOut,0,false,0),{CFrame=part.CFrame+Vector3.new(0,5,0)})
local tween2=ts:Create(part,TweenInfo.new(2.5,Enum.EasingStyle.Bounce,Enum.EasingDirection.InOut,0,false,0),{CFrame=part.CFrame+Vector3.new(0,0,0)})

tween1.Completed:connect(function() tween2:Play() end)
tween2.Completed:connect(function() tween1:Play() end)
tween2:Play()
game.Selection:Set({part})
workspace.CurrentCamera.CFrame=CFrame.new(Vector3.new(-11,7,11),part.CFrame.p)

This will insert a part, then it will tween it up and down, like an animation. Run the command in the command bar.

For the sake of using the plugin, you need to add a HumanoidRootPart to your rig. Realistically though, you don’t need this part - only have it in so the plugin accepts being able to animate your parts. The rest of your parts should be looking towards a different root unrelated to the temporary HumanoidRootPart.

Once you have that in, make sure to weld all parts together using Motor6Ds. You can do this with a plugin or through code that goes through the model and welds each part to your main root. You’re good to go once that’s been done.

I also recommend using pa00’s TweenSequence Plugin if you want to make an advanced animation with a little scripting. I don’t use it, however, but I recommend it.

I also recommend to make sure you are using TweenService on the client side to prevent “TweenService lag” (not lag as in high ping) (I use SteadyOn’s TweenService V2 Module to help that out)

Also, here’s a gif of what happens when you run the example use script.
woahcoolgif

Also, I do not recommend using Humanoids when animating parts. It’s easier, however, it can cause in-game lag if there is an overuse of Humanoids and the animation has to load first in order to use.

1 Like

Humanoids WILL cause lag. They are extremely expensive for whatever reason and it’s generally a bad practice to use them at all if you can avoid them.

2 Likes

Most of the expense comes from the backend. There’s so many factors as to why Humanoids are expensive and a lot of it chalks up to what they do per frame.

Typically, one of the first steps to reducing the expense of a Humanoid is disabling states that you know won’t be necessary for a Humanoid’s lifetime.

1 Like

True, but the worst part is that they are generally inefficient even with the states disabled. That gets worse knowing that they are the only way to make dynamic shadows with voxel lighting (unless that changed).

1 Like