Here is my code:
-- module script
local function runDroppers(Baseplate)
local ranNum = Random.new(tick())
local purchasedItems = Baseplate:FindFirstChild("PurchasedItems")
local debris = game:GetService("Debris")
local oreToClone = Instance.new("Part")
local cash = Instance.new("NumberValue")
if purchasedItems then
local itemsTbl = purchasedItems:GetChildren()
purchasedItems.ChildAdded:Connect(function(child)
table.insert(itemsTbl, child.Name)
end)
while Baseplate do
wait(2)
local newTbl = {}
if #itemsTbl > 0 then
for i,v in pairs(itemsTbl) do
wait()
if v:FindFirstChild("ItemType") then
if v.ItemType.Value == "Dropper" then
table.insert(newTbl, v.Name)
end
end
end
for i = 1, #newTbl do
wait(.3)
local ranIndex = ranNum:NextInteger(1, #newTbl)
local dropper = purchasedItems:FindFirstChild(newTbl[ranIndex])
if dropper then
local oreValue = dropper:WaitForChild("OreValue")
local dropperPart = dropper:WaitForChild("DropperPart")
table.remove(newTbl, ranIndex)
if oreValue and dropperPart then
local newOre = oreToClone:Clone()
newOre.Name = "Ore"
newOre.Size = Vector3.new(1, 1, 1)
newOre.Position = dropperPart.Position
newOre.Parent = dropper
local newCash = cash:Clone()
newCash.Name = "Cash"
newCash.Value = oreValue.Value
debris:AddItem(newOre, 20)
newCash.Parent = newOre
end
end
end
end
end
end
end
return runDroppers
What this is supposed to do is have the droppers drop the ores in a random order every couple of seconds. The problem is that they drop it in a random order, but it is the same random order ever time after the first loop. I tried rejoining the game and it was a different order that time but it stayed the same order even though it was different. The second question I have is: Is this even the most effective way to go about what I am trying to do? Thanks!

4 comments
"100% random order" is actually not entirely true. Yes, it is unpredictable since you're using a dynamic time value, but the number itself is still calculated under the same rules. Fundamentwlly "random," though.
look at line 4
I think that you should read up a little on Random.new()
thought Random.new() was just a C# thing, huh