Animation no load?

hi robloxians,
i made script that should load animation on player when using tool and is no load the animation.
here is the script:

local hum = script.Parent

local Animation = Instance.new("Animation")

Animation.Name = "ToolShakeAnimation"

Animation.AnimationId = "rbxassetid://".."5239115727"

local Rps = game.ReplicatedStorage

Rps.Events.ToolEvent.Animation.OnClientEvent:Connect(function(PlayAnimation)

hum.Humanoid:LoadAnimation(Animation)

end)

error:
there is no error at output.
thanks for help and have a great day.

This article about Animations will help you a lot (scroll to the very bottom where the code is for your specific problem addressed here), but I’ll give you more information specific to your problem so you get a better idea.


Your script is right - you just didn’t do anything with the loaded animation. Also, you should put a variable for this line:

hum.Humanoid:LoadAniamtion(Animation)

to look something like this:

local toolShake = hum.Humanoid:LoadAniamtion(Animation)

So you now have a reference to the loaded animation. Now all you have to do is play the animation by doing this:

toolShake:Play()

Your code now should look something like this:

    local hum = script.Parent

    local Animation = Instance.new("Animation")

    Animation.Name = "ToolShakeAnimation"

    Animation.AnimationId = "rbxassetid://".."5239115727"

    local Rps = game.ReplicatedStorage

    Rps.Events.ToolEvent.Animation.OnClientEvent:Connect(function(PlayAnimation)
    --- The two lines below are the ones I added/adjusted.
    local toolShake = hum.Humanoid:LoadAnimation(Animation)

    toolShake:Play()

end)

Come back if you have any issues!

2 Likes