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

Animation will not play?

Asked by 3 years ago
Edited 3 years ago

I am currently working on a game. In this game you can vault, and i need an animation to play when you do so. Sadly, i wasn't able to make the animation play.

Script in the object to vault over (server):

script.Parent.Touch.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    print(hit.Name.." touched.")
    if humanoid then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)

        hit.Parent:FindFirstChild("VaultEvent"):FireClient(player)

        print("Client has been fired")
    end
end)

Script in the player character:

script.Parent.VaultEvent.OnClientEvent:Connect(function(player)
    script.Parent:FindFirstChild("Humanoid"):LoadAnimation(script.Parent.VaultAnimation)
    print("Animation has been played")
end)

Any answer is appreciated!

2 answers

Log in to vote
0
Answered by 3 years ago

you forgot the play at the end

script.Parent.VaultEvent.OnClientEvent:Connect(function(player)
    script.Parent:FindFirstChild("Humanoid"):LoadAnimation(script.Parent.VaultAnimation):Play()
    print("Animation has been played")
end)
0
I guess my brain shut off. Thanks for th reply! ColdFoxy07 76 — 3y
Ad
Log in to vote
0
Answered by
mroaan 95
3 years ago

you forgot to play the animation after creating the animation track you should play it like this:

script.Parent.VaultEvent.OnClientEvent:Connect(function(player)
   local AnimTrack = script.Parent:FindFirstChild("Humanoid"):LoadAnimation(script.Parent.VaultAnimation)
AnimTrack:Play()
    print("Animation has been played")
end)

Answer this question