So I thought ths 2 lines (not buttons[v]) and buttons[v] = v will stop v from getting inserted to buttons twice, but no it still does.
local buttons = { } local num = 0 for _, v in pairs (script.Parent:GetDescendants())do if v:IsA("TextButton") and (not buttons[v])and v.Name == "l" or v.Name == "o" thn v.MouseButton1Click:Connect(function() buttons[v] = v print(buttons[v]) v.TextColor3 = Color3.fromRGB(0,255,0) num = num + 1 print(num) if num == 8 then print("bloxycola") end end) end end
How to prevent this from happening?
You need to place some parentheses around your or
pair otherwise it will read the whole thing left to right, fail, and go "Oh, v.Name
is "o"
. Good enough for me."
if v:IsA("TextButton") and (not buttons[v]) and (v.Name == "l" or v.Name == "o") then