My script adds more than one value to an IntValue when cycling through the children of a folder. I made it so that if the child of the folder's BrickColor.Name is equal to a certain colour then it should add 1 to an IntValue of the corresponding name colour.
for i, v in pairs(game.Workspace.ColouredParts:GetChildren()) do if v.BrickColor.Name == "Sea green" then game.Workspace.Counting.Green.Value = game.Workspace.Counting.Green.Value + 1 elseif v.BrickColor.Name == "Bright red" then game.Workspace.Counting.Red.Value = game.Workspace.Counting.Red.Value + 1 elseif v.BrickColor.Name == "Electric blue" then game.Workspace.Counting.Blue.Value = game.Workspace.Counting.Blue.Value + 1 elseif v.BrickColor.Name == "Eggplant" then game.Workspace.Counting.Purple.Value = game.Workspace.Counting.Purple.Value + 1 elseif v.BrickColor.Name == "Burnt Sienna" then game.Workspace.Counting.Brown.Value = game.Workspace.Counting.Brown.Value + 1 elseif v.BrickColor.Name == "Bright yellow" then game.Workspace.Counting.Yellow.Value = game.Workspace.Counting.Yellow.Value + 1 end end
the issue is when cycling through the script adds more than one to the values making it so IntValue's value is double the number of colours there actually is visible. eg if there are 2 yellows visible the IntValue displays "4".
Another way I can tell this is true is that the amount of all of the Intvalues add up to 50 when there are only 25 to add up... so,
Any help will be appreciated, thanks.
I think i solved it by looking through a table instead of gettingchildren
Parts = {} for I, v in pairs (game.Workspace.Folder:GetChildren()) table.insert(Parts, v) for I, v in pairs(Parts)
forgot to post this a long while ago