Preventing wait chains

A question that that has been bothering me ever since i’ve started to increase my Lua knowledge

How could we prevent tssk.wait() chains? Specifically talkimg about Animations over 1 to 2 minutes
I was thinking Animation Events could just patch this problem.


return = {
["Rush Attacks"] = {
["Character1"] = {

["E"] = function()

animation1()

task.wait(1)

animation2()

setHihghlight()

task.wait(1) 

--28 more task.waits


end)

}
}

}


Whats a better way of doing this?
2 Likes

This may help..

AnimationTrack Methods

AnimationTrack Methods (Quick Reference)

Play(fadeTime, weight, speed)
Starts the animation.
fadeTime – blend-in time (seconds)
weight – influence when blending with other animations
speed – playback speed multiplier

Stop(fadeTime)
Stops the animation.
fadeTime – time to smoothly fade it out

AdjustSpeed(speed)
Changes playback speed while the animation is running.
1 = normal, 2 = double speed, 0.5 = half speed

AdjustWeight(weight, fadeTime)
Changes how strongly the animation blends with others.
weight – new influence value
fadeTime – time to reach that weight

GetTimeOfKeyframe(keyframeName)
Returns the time position (seconds) of a named keyframe in the animation.

GetMarkerReachedSignal(markerName)
Returns an event that fires when a marker with this name is reached in the animation.

GetPropertyChangedSignal(property)
Returns an event that fires when the specified property changes.

GetDebugData()
Returns a table of internal debug information about the animation track.

1 Like

first of all why are you setting return to a table.

read this:
https://create.roblox.com/docs/reference/engine/classes/AnimationTrack

atp start vibe coding bruh. its over.

2 Likes
AnimationQueueData = {
{f = animation1; Yield = 1};
{f = animation2; Yield = 1};
{f = setHihghlight; Yield = 1};
...
}

for _,AnimationData in pairs(AnimationQueueData) do
AnimationData.f()
task.wait(Yield)
end

Although this only assumes you want different values of time waited between each animation function. Otherwise you don’t even need to have the yield value inside the AnimationData and can replace task.wait(AnimationData.Yield) with task.wait(1)

Another thing is if you are just using task.wait to yield the thread till the animation ends you can just add inside your animation1() type functions AnimationTrack.Ended:Wait() and then you don’t even need a task.wait

1 Like

It was a quick example… i obviously do not code like this🙏

1 Like

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