I have a chain of promises that run each phase of my game round, each phase is a different function and has an onCancel and a resolve condition, here’s an example:
return Promise.new(function(resolve, reject, onCancel)
onCancel(function()
warn("Intermission cancelled") --Never runs
end)
IntermissionCountdown.Changed:Connect(function(newTime)
if newTime <= 0 then
resolve()
warn("Intermission phase has ended")
end
end)
end)
Here’s where I cancel the promise.
local myPromise = Promise.new(function(resolve, reject, onCancel)
Intermission()
:andThen(Voting)
:andThen(Hiding)
:andThen(Round)
:andThen(Escape)
:andThen(function()
resolve()
end)
end)
GameStatus.Changed:Connect(function(newValue)
if newValue == false then
print("Cancelling promise")
myPromise:cancel()
end
end)
The ‘cancelling promise’ prints so I’m sure it cancels but onCancel never seems to run.