(Solved) Need help dealing random no duplicate cards

I am making a card game with 100 unique cards. Each card is it’s own object. I would like to deal out 5 random cards and no card in the game can be duplicated. I have read various links to learn about arrays and I cannot figure it out.

Does anyone have any similar working examples?

At beginning of game, I am trying to create 5x game cards that will be unique (no duplicates).

Does anyone have any ideas?

This little beauty has gotten me out of so many scrapes:

You need to ignore the first sub event that’s just if you want to refill the array if you run out of values.

The last sub event is the one you need. First you assign var R to a random number from 0 to your child count -1, then you assign var Value to the value stored in the index R - he used numbers so he could just do that +tostring to his names and I guess change position based on them too. I usually use either an object or animation name there. Then you remove the variable at index R and create your object.

1 Like

Thank you very much for such an amazing reply. Looks exactly like what I needed. I won’t be able to try until the next few days but it looks great. I will post how it works for me

Thanks again

*** yes this worked for me. Thanks again.

This documentation can help:
https://wiki.gdevelop.io/gdevelop5/tutorials/randomness/#pick-cards-from-a-deck

1 Like