#set lim before using scoreboard players operation #a srand *= #a m scoreboard players operation #a srand += #a c scoreboard players operation #a srand %= #a p scoreboard players operation #a randr = #a srand scoreboard players operation #a randr %= #a lim #result in randr