Script adding more than one to an IntValue?
Asked by
3 years ago Edited 3 years ago
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.
01 | for i, v in pairs (game.Workspace.ColouredParts:GetChildren()) do |
03 | if v.BrickColor.Name = = "Sea green" then |
04 | game.Workspace.Counting.Green.Value = game.Workspace.Counting.Green.Value + 1 |
06 | elseif v.BrickColor.Name = = "Bright red" then |
07 | game.Workspace.Counting.Red.Value = game.Workspace.Counting.Red.Value + 1 |
09 | elseif v.BrickColor.Name = = "Electric blue" then |
10 | game.Workspace.Counting.Blue.Value = game.Workspace.Counting.Blue.Value + 1 |
12 | elseif v.BrickColor.Name = = "Eggplant" then |
13 | game.Workspace.Counting.Purple.Value = game.Workspace.Counting.Purple.Value + 1 |
15 | elseif v.BrickColor.Name = = "Burnt Sienna" then |
16 | game.Workspace.Counting.Brown.Value = game.Workspace.Counting.Brown.Value + 1 |
18 | elseif v.BrickColor.Name = = "Bright yellow" then |
19 | game.Workspace.Counting.Yellow.Value = game.Workspace.Counting.Yellow.Value + 1 |
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.