I want to make an RNG game, basically it’s where cubes with varied properties fall from the sky with each property having it’s own rarity. I already have a baseplate (500x1x500) with its center positioned at the origin (0, 0, 0) with a player spawner above the origin at (0, 0.75, 0), the 4 invisible walls (502x500x2) around the baseplate at locations (-251, 250.5, 1), (1, 250.5, 251), (251, 250.5, -1), and (-1, 250.5, -251), the basic cube properties that fall from the sky, and the debris cleanup that despawns the cubes.
local cubes = {}
local lastCubeSpawnTime = 0
local cubeSpawnInterval = 1 -- seconds
while true do
-- Check if it's time to spawn a new cube
if tick() - lastCubeSpawnTime >= cubeSpawnInterval then
lastCubeSpawnTime = tick()
local cube = Instance.new("Part")
cube.Name = "BasicCube"
cube.Size = Vector3.new(4, 4, 4)
cube.Position = Vector3.new(math.random(-250, 250), 1000, math.random(-250, 250))
cube.Anchored = false
cube.Parent = game.Workspace
table.insert(cubes, cube)
-- Schedule the cube to despawn after 60 seconds
game:GetService("Debris"):AddItem(cube, 60)
end
wait()
end
Now I want to make a rarity property regarding color. How rarity properties work is that every basic cube that is about to fall from the sky goes through a script that stores rarity categories. I want to start with rarity category of color. How the color rarity category works is that basic cubes goes through a check of 1/765 to gain the rarest color, black with the spawn rate 1/765, if they didn’t get the black rarity check they will go through a check of 1/764 to gain the 2nd rarest colors. (The colors who have a 1/764 rating are RGB (1, 0, 0), (0, 1, 0), and (0, 0, 1) This will repeat until a check is successful and the cube will spawn with a random color from that specific rarity. I have tried doing this several time but I couldn’t find a good way to format it.