Basically, I’m making a window, which you can block off with wood by clicking on it. It already has 5 ‘wood’ parts inside of it, which become visible when chosen, and after they have become visible, they get removed from the table containing the left over pieces of wood.
My issue is that, it still prints the name of (which means they got chosen to be placed) parts that have already been placed, but I have used table.remove on it.
Script:
script.Parent.MouseClick:Connect(function(plr)
local currentwood = plr:FindFirstChild("Wood")
local woods = {}
for i, wood in ipairs(script.Parent.Parent:GetChildren()) do
if wood:IsA("Part") and wood.Material == Enum.Material.Wood then
table.insert(woods, wood)
end
end
if currentwood.Value > 1 then
--local num = math.random(1, #woods)
local thepart = woods[math.random(1, #woods)]
print(thepart.Name)
thepart.Transparency = 0
table.remove(woods, table.find(woods, thepart))
--return
end
end)
The concept might sound a bit confusing, it’s just about the table part.