Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how can i animate a player?

Asked by 6 years ago
Edited 6 years ago

I am trying to animate and watched a video about it, but for some reason the code works on a npc, but not on a player:

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=1574345273"

local trackanimation = nil
local playability = true
function playAnimation(AnimationSource)
    if playability == true then
        local plr = game.Players.LocalPlayer
        trackanimation = plr.Character:WaitForChild("Humanoid"):LoadAnimation(animation)
        trackanimation.KeyframeReached:Connect(function()
            print("Works")
        end)
        trackanimation:Play()
        print("play")
    end
end

script.Parent.MouseButton1Click:Connect(playAnimation)
0
Please code block your code. To do so, highlight your code then press the blue Lua button (It's near Bold, Italic, etc). Or press the code block button then paste your code within. alphawolvess 1784 — 6y
0
thanks, ill edit it saveourwolves 2 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

It works on an NPC because it's in a ServerScript.

You probably need a LocalScript,

Ad
Log in to vote
0
Answered by 6 years ago

It's likely your animation is being overlapped by the movement animations that Roblox has put in place by default - circumvent this by going in the animation editor - going to "Edit" in the plugin, and then changing the animation priority to whatever the bottom one is - I believe it is movement, which is the highest level animation. After you set it to the highest level animation priority, reexport it to Roblox, overwriting your previous animation.

Let me know if this helps any. :)

Answer this question