What do you need to do ?
A for loop ? math.random() ?
Some help on here please.
math.random()
If you wanted it to be, say, a 1 in 5 chance:
if math.random() <= 1/5 then -- Boom, golden brick! end
I mean, I myself would use Int Values and math.random
if math.random(1, 100) <= script.Chance.Value then
Another way of solving this is to have some sort of rarity
variable, where a golden brick has a 1 in rarity
chance of appearing. Making the rarity of the brick bigger means that it is more rare!
local GOLDEN_BRICK_RARITY = 100 -- this means that 1 in 100 bricks spawned will be golden. Setting this to 1 means a golden brick will ALWAYS spawn. function SpawnBrick() if math.random(1, GOLDEN_BRICK_RARITY) == 1 then -- TODO: Spawn a golden brick else -- TODO: Spawn a regular brick. end