Waiting for one of two events to fire

So right now im working on an animation system which freezes the player while the animation plays, however if the player switches tool while the animation is playing Track.Stopped does not fire , so how would I modify this code to make ‘1’ print when ither a. the animation finishes, b. the tool is unequipped 30

I think you need to have a tool.equiped function to set a flag then use that flag inside this module.

1 Like

I have always used a sort of hacky method to do this.

local condition = false

local conn, conn2

conn = Track.Stopped:Connect(function()
conn:Disconnect()
conn2:Disconnect()
condition = true
end)

conn = Tool.Unequipped:Connect(function()
conn:Disconnect()
conn2:Disconnect()
condition = true
end)

repeat wait() until condition
1 Like

eh, I knew I could do this, I was just wondering if there was a simpler more memory efficient way :confused:

1 Like

It’s quite easy with BindableEvents if used as the following:

2 Likes