Alright, I am trying to make a part collecting billboard GUI pop up system that displays a number total based by color (part’s StringValue.Value)
Meaning, if there were 10 parts being collected at once, 5 were red and the other 5 were blue then it would add the 5 red parts together and displaying its total then adding the 5 blue parts together and also displaying its total separately. (like +5 red gui and +5 blue gui)
Anywho, the problem I am facing is that my code is not grouping these parts together by the color that my RNG script assigned them. Instead its displaying a Billboard Gui for EVERY part being collected, when Im trying to get them grouped, added together, then showing the combined total.
Example of whats wrong here.

What I wanted is the orange to be +6 and the brown to be +4 instead of whats shown.
Right now I am putting the parts into a table, then using a for in pairs loop to loop through the table and using if/ elseif statements to see what StringValue(color name) the part’s decal has and trying to add those together to a variable. Then after the loop, if there was an added total more than 0, then it generate a Billboard gui and display the total. Then after that I set the totals back to 0 and make every key in the table nil with another in pairs loop.
here is the part of the script I am having trouble with. Not sure my logic here is correct. (Parts were detected with an invisible explosion)
--- code that I need help with here \/
elseif Kibble.Digs.Value <= 15 and Kibble.Digs.Value > 0 then
--- the table for adding by colors
local KibbleTable = {}
--------------------------------
table.insert(KibbleTable, Kibble)
wait(KibbleWait.Value)
--- blah irrelevant code blah
---
----------------------------------------
local BrownTotal = 0
local OrangeTotal = 0
for _, KibbleT in pairs(KibbleTable) do
print(KibbleT)
local KibbleMultipliedT = KibbleT:FindFirstChildWhichIsA("Decal"):FindFirstChildOfClass("IntValue")
local KibbleTextColorT = KibbleT:FindFirstChildWhichIsA("Decal").TextColor -- StringValue
-- Browns
if KibbleTextColorT.Value == "Brown" then
BrownTotal = BrownTotal + KibbleGive.Value * KibbleMultipliedT.Value -- KibbleGive is IntValue inside tool, multiplied is IntValue inside decal of Kibble part
-- Oranges
elseif KibbleTextColorT.Value == "Orange" then
OrangeTotal = OrangeTotal + KibbleGive.Value * KibbleMultipliedT.Value
end
end
if BrownTotal > 0 then
local HitmarkerClone = ServerStorage:WaitForChild("Hitmarker"):Clone() --- will be making this local later, testing on server for now
HitmarkerClone.ExtentsOffsetWorldSpace = Vector3.new(0, (math.random(-70,170)/100), (math.random(-100,100)/100))
HitmarkerClone.Frame.TextLabel.Text = "+"..BrownTotal
HitmarkerClone.Frame.TextLabel.TextColor3 = Color3.fromRGB(147,102,39)
HitmarkerClone.Parent = player.Character
wait(1)
HitmarkerClone:Destroy()
end
if OrangeTotal > 0 then
local HitmarkerClone = ServerStorage:WaitForChild("Hitmarker"):Clone()
HitmarkerClone.ExtentsOffsetWorldSpace = Vector3.new(0, (math.random(-70,170)/100), (math.random(-100,100)/100))
HitmarkerClone.Frame.TextLabel.Text = "+"..OrangeTotal
HitmarkerClone.Frame.TextLabel.TextColor3 = Color3.fromRGB(255,140,0)
HitmarkerClone.Parent = player.Character
wait(1)
HitmarkerClone:Destroy()
end
BrownTotal = 0
OrangeTotal = 0
for k in pairs(KibbleTable) do
KibbleTable[k] = nil
end
end
end
end)
end
I made a post for this last night, but I thought I didnt explain it well so I took it down and made a fresh post.
TY for reading o/
