How Can I Check If An Animation Id Is Valid?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to make It so If the animation id is valid it returns true

  2. What is the issue? I Cant seen to figure out how

  3. What solutions have you tried so far? Ive looked everywhere and tried to come up with a solution with no success

b = Instance.new("Animation", workspace)
b.AnimationId = "rbxassetid://"..Animation
c = workspace.Dummy.Humanoid:LoadAnimation(b)
c.Looped = true
c:Play()
wait(3)
print(a.IsLoaded)
if c.IsPlaying then

Ive tried to do this but It still passed through as true

You can use a pcall:

local Animation, Error = pcall(function() -- Animation is the returned value, while error is the error message if something goes wrong
    local b = Instance.new("Animation", workspace)
    local b.AnimationId = "rbxassetid://"..Animation
    local c = workspace.Dummy.Humanoid:LoadAnimation(b)
    return c -- returned value
end)

If Animation then
    Animation:Play() -- Plays if nothing is wrong
else
    print(Error) -- Prints in something goes wrong
end
3 Likes