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

How do i preload an animation?

Asked by 4 years ago
local ContentProvider = game:GetService("ContentProvider")

local anim = "rbxassetid://3965998277"

local animation = Instance.new("Animation")
animation.AnimationId = anim


spawn(function()
local asset = {anim}
ContentProvider:PreloadAsync(asset)
print("loaded")
end)
print("xd")
game.ReplicatedStorage.hit1.OnServerEvent:Connect(function(player)
    local anims = player.Character.Humanoid:GetPlayingAnimationTracks()
    for i, track in pairs (anims) do
        track:Stop()
    end
    local anim2 = player.Character.Humanoid:LoadAnimation(animation)
    anim2:Play()
end)

I'm attempting to preload the animation, because it doesn't work in game at the moment.

Answer this question