Mouse1ButtonClick not firing when nesting connection within promise.
I am unable to get this promise to resolve. do you guys see anything inherently wrong with how i am resolving this promise?
selectCard(filterFunc? : (card : ClientCard) => boolean) {
const cards = filterFunc === undefined ? this.listOfCardUI : this.listOfCardUI.filter(card => filterFunc(card.getClientCard()))
return new Promise<ClientCard>((resolve, reject) => {
let connections : RBXScriptConnection[] | undefined = undefined
connections = cards.map(card => card.getElement().MouseButton1Click.Connect(
() => {
resolve(card.getClientCard())
})) }) }
})) }) }

3 Replies
why do you want to put it in promise?
there's Promise.fromEvent i think
where you can just do
const value_promise = Promise.fromEvent(card.getElement().MouseButton1Click)
The server waits and gives the player X amount of time to pick a card
so I put it in a promise to state that we are waiting for the player to pick a card
Is there another approach you'd take?
oh
i'd put in the controller or smth
and it depends on what ui you have i think