I plan to make a new revolutionary Roblox experience (will be called “Guess Yourself”).
It will require me to get familiar with the Roblox animations.
I slightly modified first example from the official animation docs: changed the ID to the animation I made, removed the bit with animation events and (eventually) added task.wait() call:
(LocalScript placed inside StarterPlayerScripts)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local kickAnimation = Instance.new("Animation")
kickAnimation.AnimationId = "rbxassetid://118986049327664"
local kickAnimationTrack = animator:LoadAnimation(kickAnimation)
kickAnimationTrack.Looped = true
task.wait() -- remove this and it will not work. Note - no wait time being passed
kickAnimationTrack:Play()
Without task.wait() the animation will not play. I get no errors about it, everything seems to be loaded and ready to go.
Why does this happen? I assume it could be one of the following:
a) this is not how aminations should be used (start blasting some animation right when a character loads in)
b) there is some timing quirk that I should be aware of
Hi, i tested this code with improvement. For some reason animation is playing, but doesn’t show in game. I think animation can be played only after some time passed. By the way, if you code task.wait() without number, script also wait some time, as i know ~0,016 sec. Sorry for bad English
The reason of this is cause animations dont instantly load, if you play the animation without the task.wait, at that point the animation wouldnt have loaded.
From the look of it I wouldn’t worry about it, as it shouldn’t matter to much.
In the case that you need an animation to play at an exact time, I would recommend loading an animation the second the players character loads in.
But again in this case, there isnt a reason to worry about it, as its only a 0.03 second difference.
If I recall correctly the minimum a task.wait can well, wait is 0.03, so unless roblox updated it not to long ago, I believe task.wait() when blank, or waiting 0 seconds, will actually wiat 0.03 seconds.
I will assume this was the case. Added a while loop to wait until animation track property Length is not zero, and the animation played. Thought it would error out or would wait to load if I tried to play it before it is fully loaded