How do I pick a random player for a function?

All I have so far is this but it’s just sticking to one person and not being random I’m not really sure how to fix it I was thinking something with GetRandomInt but I’m not sure how to use that either haha thanks!

BossAutoAttack()<suspends> : void =        
        loop:
            Sleep(3.0)
            Playspace : fort_playspace = GetPlayspace()
            AllPlayers :  []player = Playspace.GetPlayers()
            Shuffle(AllPlayers)
            if (FirstPlayer : player = AllPlayers[0]):
                if (FortniteCharacter : fort_character = FirstPlayer.GetFortCharacter[]):
                    FortniteCharacter.Damage(4.0)

Shuffle will return a shuffled array, it doesn’t actually mutate AllPlayers. You would need to do

ShuffledPlayers := Shuffle(AllPlayers)
if (FirstPlayer : player = ShuffledPlayers[0]):

or

if (FirstPlayer := Shuffle(AllPlayers)[0]):
4 Likes

that fixed it!! Thank you so much!! :smiley: also that’s good to know about Shuffle lots to learn haha

1 Like

I was wondering if i could do the same thing but in a specific team ?