Choosing random element from a table with rarity

the script is supposed to spawn a random element every 10 seconds but it only spawns wind its not a coincidence i tried it a lot of times and waited for long
i watched the tutorial from alvinblox for egg hatching system

local Spawns = workspace.map:WaitForChild("ElementSpawns"):GetChildren()
local ElementParts = game.ServerStorage.ElementsParts

local Elements = {
	["Common"] = {
		ElementParts.Fire
	},
	["Uncommon"] = {
		ElementParts.Water
	},
	["Rare"] = {
		ElementParts.Wind
	},
	["Epic"] = {
		ElementParts.Earth
	},
	["Legendary"] = {
		ElementParts.Lightning
	}
}

local Rarity = {
	["Common"] = 50,
	["Uncommon"] = 30,
	["Rare"] = 10,
	["Epic"] = 7,
	["Legendary"] = 3
}

while true  do
	local r = Spawns[math.random(1, #Spawns)]
	local Number = math.random(1, 100)
	local Counter = 0
	local element
	
	for rarity, weight in pairs(Rarity) do
		Counter = Counter + weight
		if Number <= Counter then
			local RarityTable = Elements[rarity]
			element = RarityTable[math.random(1, #RarityTable)]:Clone() --choose an element from the Elements table
			print(RarityTable, Counter, element)
			
		end
	end
	
	r:WaitForChild("ProximityPrompt").Enabled = true
	element.Position = r.Position
	element.Parent = r
	task.wait(10)
	element:Destroy()
	r:WaitForChild("ProximityPrompt").Enabled = false
end

You should add break after the new “element” is chosen. This cancels the entire for loop and goes onto the next thing because the element had been chosen, if you don’t put a break then it just goes on forever and you’re cloning multiple elements.
So the if statement in the for loop would look like this:

if Number <= Counter then
			local RarityTable = Elements[rarity]
			element = RarityTable[math.random(1, #RarityTable)]:Clone() --choose an element from the Elements table
			print(RarityTable, Counter, element)
			break
		end
Weight system
local function pickItem()
	local items = {
		Common = 75,
		Uncommon = 20,
		Rare = 10,
		Epic = 5,
		Legendary = 1
	}

	local total = 0
	for _, weight in pairs(items) do total += weight end

	local roll = math.random() * total
	for item, weight in pairs(items) do
		roll -= weight
		if roll <= 0 then return item end
	end
end

print("Item:", pickItem())
Added to your script
local Spawns = workspace.map:WaitForChild("ElementSpawns"):GetChildren()
local ElementParts = game.ServerStorage.ElementsParts

local Elements = {
	Common = {ElementParts.Fire},
	Uncommon = {ElementParts.Water},
	Rare = {ElementParts.Wind},
	Epic = {ElementParts.Earth},
	Legendary = {ElementParts.Lightning}
}

local Rarity = {
	Common = 50,
	Uncommon = 30,
	Rare = 10,
	Epic = 7,
	Legendary = 3
}

local function pickElement()
	local total = 0
	for _, weight in pairs(Rarity) do total += weight end
	local roll = math.random() * total
	for rarity, weight in pairs(Rarity) do
		roll -= weight
		if roll <= 0 then
			local items = Elements[rarity]
			return items[math.random(1, #items)]:Clone()
		end
	end
end

while true do
	local r = Spawns[math.random(1, #Spawns)]
	local element = pickElement()
	r:WaitForChild("ProximityPrompt").Enabled = true
	element.Position = r.Position
	element.Parent = r
	task.wait(10)
	element:Destroy()
	r:WaitForChild("ProximityPrompt").Enabled = false
end