Hello guys,
im stuck trying to give each player a random trait from a list of 10, the idea is when the game starts each player has random 3 traits that others can see ( one can be the same but no more than one)
Hey @Kloaker! Welcome to the forums!
So this is standard array stuff, no worries!
First, check if TraitNames LENGTH < 3. If that is true(branch):
GET (a copy) of your list of possibilities array, get random, and Add Unique, (not just Add) to your Character’s list of TraitNames. This prevents duplicates. Then at the end of that, loop the execution line around to before the LENGTH < 3 check. Once it triggers “False” meaning it has >3 traits, it will break the loop and you are done, the False is your exit. Hope that helps!
(post deleted by author)
many many thanks for the hand,
Now it works—it gives me 3 random traits and assigns them. The problem is, a single player shouldn’t have duplicate traits, but most of the time they end up with 2 or even all 3 traits being the same.
See, it shouldn’t be able to do that.
Add Unique specifically is for when you want to check if something is already in an array and refuse to add it if it’s already there.
You have another event in the mix here, you really should rename something because you definitely don’t want two things being too close to the same name as it is here, the only difference is the “s” at the end.
It has to be something involved with that other event you’re calling here, alternatively you’re seeing duplicates because every time this runs it’s running a new ForEachLoop. Try hooking the ForEachLoop up to the False end of the Branch at the start, that way it will only print when they hit 3 instead of every time this runs.
