Any better way to do Animation.Looped = false?

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

  1. What do you want to achieve? Keep it simple and clear!
    I want to do AnimationTrack.Looped = false
  2. What is the issue? Include screenshots / videos if possible!
    No issue, just wondering if there’s better solution , because roblox is kinda weird when it comes to animations!
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried to wait for animationTrack.Length
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
function WaitUntilAnimationIsLoaded(animation)
	repeat wait() until animation.Length>0
	return true
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

don’t overthink it man, you’re overcomplicating it.

1 Like

Bro this goes in Code Review, but if your script is already working then I’d say its perfectly fine.

Now, if I remember correctly, there should be an event called “.loaded” where it will trigger when an animation has fully loaded. something like:

"NameOfAnimation".loaded:Connect(function()
   animation.looped = false
end)

PS: Forgive me if this doesn’t work, I haven’t worked on animations for years DX.

.loaded isn’t a event?

1 Like

Ok, I definetly didn’t remember at all. :man_facepalming:
The code you presented is perfectly fine then, I wouldn’t worry about trying to change what you have because if it is not inducing any performance drops, and works as intended, what is there to change? Don’t fix whats not broken.

Basically, it’s very slow at loading so I wanted to ask if there’s Event inside AnimationTrack that detects if the animation is loaded, because I feel like its necessary, because if you call AnimationTrack.Looped = false, before animation is loaded using .Length >0 it will loop it forever.

After a little bit of googling, I found something called Animation:IsLoaded() which should return a bool value.
Looping an if statement should return a true response once the animation is loaded and from there you can call the AnimationTrack.Looped = false
After this i’m out of ideas DX

Animation:IsLoaded() doesn’t work.

your overcomplicating it no? did you originally try .Looped = false after loading it?

Funny,
I am not overcomplicating it, I am just hinting out that roblox scripting is sometimes horrible for no reason.

function WaitUntilAnimationIsLoaded(animation)
	repeat wait() until animation.Length>0
	return true
end
local animation : AnimationTrack = Animator:LoadAnimation(Animation)
animation.Looped=false -- this won't turn the animation.Looped to false test by using
print(animation.Looped) -- This will print true if animation is looped by animator.
WaitUntilAnimationIsLoaded(animation) -- This function waits until animation has Length
animation.Looped=false -- Finally we can turn animation Looped to false
print(animation.Looped) -- This finally prints false

Another complicated situation

local Part = Instance.new("Part",workspace)
Part:SetNetworkOwner(player) -- Makes the Network Owner to the Player
instance.new("Part",Part) -- Part gets new Part inserted
Part:GetNetworkOwner() -- Somehow Network owner is now Server```

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.