Why does this Set variable allow duplicates?

Hey there, I am working on a memory game with random answers, to do this I create a Set from a randomly selected integers between 1 and 25, 25 being the amount of buttons there are in the memory game.

But when I generate the integers and add them to the set for some reason it allows duplicates in the set while sets are only supposed to have unique items?

Am I understanding sets wrong or is there a bug?

Code used to generate the set.

Outcome clearly shows multiple instances of 18.
MultipleAddedtoset

And I stand totally corrected. You can’t have dupe elements in an Unreal set, but I’m sure you can mathematically…

Apparently you can in a multi-set, but not a normal set…

That’s because your code calls Random Integer In Range twice: first time for the check, and another time to set the value.
What you want to do is save your random value to a variable at the very beginning of this function, and then only work with that variable, not with the Random Integer In Range node.

3 Likes

Thank you, it was indeed just a case of saving the variable before hand.

I just assumed the value generated would be the same.

This is the solution for anyone who wants reference in the future.