Hi, DevForum. For the first time, ChatGPT did not help. In my game, a grid of parts will spawn, with some parts being special (by chance). How can I make sure that there is a certain number of special parts in the grid?
local function createBlock(position, size, material, color)
local block = Instance.new("Part")
block.Size = size
block.Anchored = true
block.Material = material
block.Color = color
local chance = math.random(1, specialBlockChance or 150)
if chance == 1 then
registerSpecialBlock(block)
end
-- Pick a random shape
block.Shape = shapes[math.random(1, #shapes)]
block.Position = position
-- Tag as DigBlock
CollectionService:AddTag(block, "DigBlock")
block.Name = "Block"
block.Parent = folder
end