Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would i delete the oldest part?

Im trying to make a dropper like in a tycoon but i cant get it to delete the parts right. Once the limit is reached the ore never reaches the ground. What im trying to do is it'll delete ore that has already fell.

local dropper = script.Parent.Laser.Dropper
local count = 0
local limit = 50
while true do
	wait(0.1)
	if count <= limit then
		count = count + 1
		drop = script.Parent.Ore:Clone()
		drop.Position = dropper.Position + Vector3.new(-5,0,0)
		drop.Parent = dropper
		drop.Transparency = 0
		drop.Anchored = false
		drop.CanCollide = true
	else
		count = count - 1
		ore = dropper:FindFirstChild("Ore")
		ore:Destroy()
	end
end

1 answer

You could store the ores in a table, and then iterate through the table and destroy them using a for loop.

Let me know if this isn't what you're going for, so I can edit my answer :)

local dropper,count,limit = script.Parent.Laser.Dropper,0,50
local ores = {} --Table to store ores

--Function to clear ores
function clearOres()
	for _,v in next,ores do
		count = count - 1
		v:Destroy()
		wait(.1)
	end
end

while wait(.1) do
	if count < limit then
		count = count + 1
		drop = script.Parent.Ore:Clone()
		drop.Position = dropper.Position + Vector3.new(-5,0,0)
		drop.Transparency = 0
		drop.Anchored = false
		drop.CanCollide = true
		drop.Parent = dropper
		ores[#ores+1] = drop --Add ore to the table
	else
		clearOres() --Call the clearing function
	end
end

1 comment

0

This is close but im looking for something that deletes ores constantly instead of placing them all then removing.

This discussion is preserved as it was. New answers, comments, and votes are closed.