What is the correct way to script animations?

Hello! I would like to know if someone could share code with me to know how to script an animation in an updated way, since my code is very outdated. :frowning: pease

Otherwise, could you tell me how to play an animation correctly please :frowning:

Example:

local Animation = Instance.new("Animation")
local Animator = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
Animation.AnimationId = "rbxassetid://ID"
Animator:LoadAnimation(Animation):Play()

Read here for guidance on where to play animations depending on your usecase.

2 Likes

Thanks you a lot! and what about stop to stop the animation?

AnimationObject:Stop()

You can read more on animations in the link I provided in my previous post.
No problem!

1 Like

Also make sure to play any animations on the client since it replicates to the server.

1 Like

Thanks you guys!! for the tips and all :smiley:

Incorrect, I suggest you read the page I linked.