So I have been having this annoying problem with an animation that at the rarest cases refuses to play and I’ve tried pretty much everything and it usually doesnt work when Im in a live server, so my speculation is that it’s a problem with just waiting but i’ve tried multiple repeat untils and the problem still persists, any ideas?
repeat game:GetService("RunService").RenderStepped:Wait() until player.Character:WaitForChild("Humanoid")
local humanoid = player.Character:WaitForChild("Humanoid")
humanoid.UseJumpPower = true
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
repeat ClientRemoteHandler.blockstart_anim = humanoid.Animator:LoadAnimation(game.ReplicatedStorage:WaitForChild("BlockStart"))
until ClientRemoteHandler.blockstart_anim ~= nil
repeat ClientRemoteHandler.blockstart_anim:Play()
until ClientRemoteHandler.blockstart_anim.IsPlaying == true
In the first repeat loop, you’re waiting for the player’s character to exist before proceeding but you’re not defining the player variable anywhere, so make sure to assign the correct value to the player variable before using it in the loop.
The second repeat loop is trying to load the animation from game.ReplicatedStorage:WaitForChild(“BlockStart”) repeatedly until it’s not nil. It’s possible that the animation is not being replicated to the client correctly or has a delay in replication causing the loop to run indefinitely. Instead of using a repeat loop, you could use a while loop that waits until the animation is loaded.
The third repeat loop is attempting to play the animation repeatedly until it’s playing (IsPlaying == true ). This may not be the most effective way to ensure the animation plays. You could play the animation once and then wait until it finishes playing before proceeding with other actions.
Like I said before it is working but at rare times like when (im in game), that’s when sometimes the animation doesn’t play because which im guessing is because it’s just running too fast, but wouldnt a repeat and a while just act the exact same???
Yeah so basically this is in a CharacterAddedEvent that is on the client, I didn’t wanna show the whole script, cause just to focus on the part that is sometimes not working
Your animation does not play because the asset that is used for your animation has not been loaded in the game which of course does not let you play it yet.
Optimal way to load your animation correctly is using ContentProvider service which gives you an advantage on preloading assets.
Honestly I’m not quite sure about this but you could try having the animation be stored in the character rather than loading it from ReplicatedStorage.
But check if the animation is authorized for the game first.
I’d like think this would work but I’m pretty sure it’s just a waiting issue because it usually happens only when im in a actual live server, so the code must be just running too fast