Compound Wait Statement

I have written this code:
newTween.Completed:Wait() or moveConfig.Speed.Changed:Wait()

Which I know doesn’t work but I want to find a way to fix it. I want for a script to yield until the tween is completed or the speed value is changed without an awkward pause at the end. Does anyone have a suggestion?

This is a little more memory-intensive, but perhaps you could set up an intermediate event to be fired when either event occurs, then wait for just that intermediate event.

local temp = Instance.new("BindableEvent")

local listen1 = newTween.Completed:Connect(function() temp:Fire() end)
local listen2 = moveConfig.Speed.Changed:Connect(function() temp:Fire() end)

temp.Event:Wait()

--cleanup
listen1:Disconnect()
listen2:Disconnect()
temp:Destroy()
1 Like

Thank you so much. My tweens look so much better!

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