Discuss Scratch

NinjaJager5
Scratcher
39 posts

code to make chance for game

Hi,

if you are reading this then i need help to make a % chance for diffrent cards for my card pack opener game can anyone answer?
kansea
Scratcher
500+ posts

code to make chance for game

if <(pick random (0) to (99)) < [25]> then
This has a 25% chance of running
end
deck26
Scratcher
1000+ posts

code to make chance for game

But if you want to check for various values in different if blocks make sure you save the random value in a variable.

set [myrand v] to (pick random (1) to (10))
if <(myrand) > [50]> then
do something
else
if <(myrand) > [20]> then
do something
else
do something
end

It makes sense to check for the most common items first so the if/else block can exit as quickly as possible rather than keep checking. In the example we have a 50% result, then a 30% result and finally a 20% result.

Last edited by deck26 (Feb. 3, 2026 14:20:06)

NinjaJager5
Scratcher
39 posts

code to make chance for game

thanks!!

Powered by DjangoBB