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