random number in a function hud

there’s a way for get random number in a function binded in hud ?( in my example need to set random array element each call, but if i set random inside this function the picture in hud change every frame and i need to get this random number 1 time for each function is called and… if i set random number outside function the number doesn’t change, result : all picture are same)