#Animation on players not working

5 messages · Page 1 of 1 (latest)

pearl ruin
#

I made a simple animation and it works fine on rigs but when i try using it on a player it wont work, and it wont give any errors, this code is just a test on a local script but even normal scripts wont make it work (i barely worked with animations so im not sure what i did wrong)

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local animation = character.Animation
local humanoid = character.Humanoid

UIS.InputBegan:Connect(function(input, GPE)
    if input.KeyCode == Enum.KeyCode.P then
        animation.AnimationId = "rbxassetid://127068582200241"
        local Track = humanoid:LoadAnimation(animation)
        Track:Play()
        print("playing animation")
    end
end)
uneven peak
#

Loading animations on Humanoids is deprecated. Using the Humanoid's animator might make it work.

Here is the new script if you need it:

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local animation = character.Animation
local humanoid = character.Humanoid
local animator = humanoid.Animator or humanoid:WaitForChild("Animator")

UIS.InputBegan:Connect(function(input, GPE)
    if GPE then return end --Just so the event doesn't fire if the player is typing.

    if input.KeyCode == Enum.KeyCode.P then
        animation.AnimationId = "rbxassetid://127068582200241"
        local Track = animator:LoadAnimation(animation)
        Track:Play()
        print("playing animation")
    end
end)
``` @pearl ruin
pearl ruin
#

yo @uneven peak, i found out that i made the animation on a r6 avatar (mine is r15) and the rig was r6, so i just made an animation for both of the models.

#

But im still gonna try using the humanoid's animator since as u said its deprecated to load the animation on the humanoid, thanks for the help tho!