# For i,v function not effecting every plate

Hello,
my “for i,v” funtion is not effecting every value

Here is my script:

Plate.Transparency = 1
Plate.CanCollide = false
Plate.Highlight:Remove()
end

wait(3)

Plate.Transparency = 0
Plate.CanCollide = true
end

end

Any solutions?

local PlatesFolder = workspace.PlatesFolder -- Folder that contains all plates

for _, Plate in pairs(PlatesFolder:GetChildren()) do -- Loops through everything in folder
if Plate:IsA("Part") then -- Checks if 'Plate' is a part
...
end
end

I am not detecting if it is a part I am detecting if it is a bad plate

I have a folder that holds 100 plates. I then randomly pick some of them and add them to a table. Now I want to go through the table and do what I want to the bad plates

local folder = FOLDER_PATH

for i = 1,#folder do
local RNG = math.random(1,2)
if (RNG%2 == 0) then
end
end

--whatever you wanna do to them here
end

I believe this is what you’re trying to achieve

In the code shown above, I find the folder with all of the plates. I iterate thru the folder, and each iteration, I pick a number between 1 and 2, inclusive (meaning it can either be 1 or 2). Depending on the chosen number, I put the plate in the “BadPlates” table which can then be used in a for i,v in pairs() loop

EDIT: If you want a max amount of bad plates in your table, you can set that as follows:

local folder = FOLDER_PATH

for i = 1,#folder do
local RNG = math.random(1,2)
end
end

--whatever you wanna do to them here
end

It already randomizes the plates and the problem I have is that not every plate is being effected by what I want to happen in the “For i,v” function.

I’m a bit confused, im assuming there is more to this script, and I would love to see the whole thing so I can understand your conditions.

By the looks of it, it resets BadPlates each loop (if you even loop it, im assuming you do) so if you add more, the previous plates in the list wont be affected.

Here is my script:

for i = 1,10,1 do
Status.Value = "Please Stand on a plate"

wait(RoundDelay)

Status.Value = "Choosing Plates"

wait(3)

if Round == 1 then
local Plate = Plates[math.random(1, #Plates)]
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(1, 0, 0)
Highlight.Parent = Plate
end
end
end
end
if Round == 2 then
local Plate = Plates[math.random(1, #Plates)]
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(1, 0, 0)
Highlight.Parent = Plate
end
end
end
end
if Round == 3 then
GoodPlatesAmount = math.random(1, 10)
for i = 1,GoodPlatesAmount,1 do
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(0, 1, 0)
Highlight.Parent = Plate
table.insert(GoodPlates, Plate)
end
end
end
if Round == 4 then
local Plate = Plates[math.random(1, #Plates)]
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(1, 0, 0)
Highlight.Parent = Plate
end
end
end

GoodPlatesAmount = math.random(1, 5)
for i = 1,GoodPlatesAmount,1 do
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(0, 1, 0)
Highlight.Parent = Plate
table.insert(GoodPlates, Plate)
end
end
end
if Round == 5 then
local Plate = Plates[math.random(1, #Plates)]
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(1, 0, 0)
Highlight.Parent = Plate
end
end
end

GoodPlatesAmount = math.random(1, 8)
for i = 1,GoodPlatesAmount,1 do
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(0, 1, 0)
Highlight.Parent = Plate
table.insert(GoodPlates, Plate)
end
end
end
if Round == 6 then
local Plate = Plates[math.random(1, #Plates)]
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(1, 0, 0)
Highlight.Parent = Plate
end
end
end

GoodPlatesAmount = math.random(1, 10)
for i = 1,GoodPlatesAmount,1 do
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(0, 1, 0)
Highlight.Parent = Plate
table.insert(GoodPlates, Plate)
end
end
end
if Round == 7 then
GoodPlatesAmount = math.random(1, 20)
for i = 1,GoodPlatesAmount,1 do
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(0, 1, 0)
Highlight.Parent = Plate
table.insert(GoodPlates, Plate)
end
end
end
if Round == 8 then
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(1, 0, 0)
Highlight.Parent = Plate
end
end
end
if Round == 9 then
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(1, 0, 0)
Highlight.Parent = Plate
end
end

GoodPlatesAmount = math.random(1, 15)
for i = 1,GoodPlatesAmount,1 do
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(0, 1, 0)
Highlight.Parent = Plate
table.insert(GoodPlates, Plate)
end
end
end
if Round == 10 then
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(1, 0, 0)
Highlight.Parent = Plate
end
end

GoodPlatesAmount = math.random(1, 25)
for i = 1,GoodPlatesAmount,1 do
local Plate = Plates[math.random(1, #Plates)]
if not table.find(GoodPlates, Plate) and not table.find(BadPlates, Plate) then
local Highlight = Instance.new("Highlight")
Highlight.OutlineTransparency = 1
Highlight.FillTransparency = .2
Highlight.FillColor = Color3.new(0, 1, 0)
Highlight.Parent = Plate
table.insert(GoodPlates, Plate)
end
end
end
GoodPlatesAmount += 1

Status.Value = ""

wait(5)

if #GoodPlates > 0 then
for i,Plate in pairs(GoodPlates) do
Plate.Highlight:Remove()
table.remove(GoodPlates, table.find(GoodPlates, Plate))
end
end
Plate.Transparency = 1
Plate.CanCollide = false
Plate.Highlight:Remove()
end

wait(3)