You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I wanna make my drill work and produce ores
What is the issue? Include screenshots / videos if possible!
This script:
local itemsfolder = game.Lighting.Ores:GetChildren()
local item = math.random(#itemsfolder)
local DrillTime = 3
if script.Parent.Mining.Value == true then
while wait(DrillTime) do
item = math.random(#itemsfolder):Clone()
item.Parent = workspace.Ores
item.Position = script.Parent.DropLocation.Position
end
end
Displays error:
13:48:36.860 Workspace.Model.Script:10: attempt to index number with 'Clone'
local itemsfolder = game.Lighting.Ores:GetChildren()
local number = math.random(#itemsfolder)
local randomItem = itemsfolder[number]
local DrillTime = 3
if script.Parent.Mining.Value == true then
while wait(DrillTime) do
number = itemsfolder[number]
randomItem = number:Clone()
randomItem.Parent = workspace.Ores
randomItem.Position = script.Parent.DropLocation.Position
end
end
local itemsfolder = game.Lighting.Ores
local Items = {}
local DrillTime = 3
for i, v in itemsfolder:GetChildren() do
table.insert(Items, v)
end
if script.Parent.Mining.Value == true then
while task.wait(DrillTime) do
local randomItem = Items[math.random(1, #Items)]:Clone()
randomItem.Parent = workspace.Ores
randomItem.Position = script.Parent.DropLocation.Position
end
end
This worked when I tested it. So try this and see if this works. ¯_(ツ)_/¯
local itemsfolder = game.Lighting.Ores:GetChildren()
local DrillTime = 3
if script.Parent.dril.Value == true then
while wait(DrillTime) do
local number = math.random(#itemsfolder)
local randomItem = itemsfolder[number]
if randomItem then
print(randomItem)
local Item = randomItem:Clone()
print(Item)
Item.Parent = workspace.Ores
Item.Position = script.Parent.DropLocation.Position
end
end