Animation issues

Hello, I would like to know what I am doing wrong :frowning: I need to make when I press the G key the animation plays, just that

local animation = Instance.new("Animation")

animation.AnimationId = "https://www.roblox.com/asset/?id=6351842291"

local AnimationController = script.AnimationController

local animationTrack = AnimationController:LoadAnimation(animation)

local UserInputService = game:GetService("UserInputService")

local function onInputBegan(input, gameProcessed)

if input.KeyCode == Enum.KeyCode.G then

-- code

animationTrack:Play()

else

animationTrack:Stop()

end

end

UserInputService.InputBegan:Connect(onInputBegan)

Try using the Animator inside the Humanoid instead of the AnimationController since it seems to be “deprecated”, if nothing happens then try adding some print() statements to debug it

AnimationController should be parent of a model instance that being animated, not script

how could i do this? :scream: :frowning:

are you playing an animation on an actual character or an object? if its an object use animation controllers, and if its a character play it on the humanoid.

1 Like

You would find it inside the Character's Model in the Humanoid