I’ve been working on making a cash register for no reason at all, and I want it to be able to input the numbers into a gui. However, when defining the click detectors and putting them inside of a table, I’ve run into a problem. The 0, 1, 5, and 8 click detectors are put in the table just fine, but the rest of them are simply nonexistent. I have no idea what is happening with this, as after click detector 8, there is a value 0 and a value nil, and that’s it. Anyone know what to do about this?
The script:
local gui = script.Parent.Parent.AF1FCSWDDCDCRB_Price.AF1FCSWDDCDCRBP_Center.AF1FCSWDDCDCRBPC_Gui.AF1FCSWDDCDCRBPCG_TextLabel
local group = script.Parent:GetDescendants()
local clickDetectors = table.pack()
local partToKeep1
local partToKeep2
local partToKeep3
for _, v in pairs(group) do
if v:IsA("ClickDetector") then table.insert(clickDetectors, tonumber(string.split(string.split(v.Name, "_")[1], "P")[2]) + 1, v) end
end
for i, v in pairs(clickDetectors) do
v.MouseClick:Connect(function()
partToKeep1 = string.sub(gui.Text, 3, 3)
partToKeep2 = string.sub(gui.Text, 5, 5)
partToKeep3 = string.sub(gui.Text, 6, 6)
gui.Text = "$" .. partToKeep1 .. partToKeep2 .. "." .. partToKeep3 .. tostring(i - 1)
end)
end
Now, important to note, if I set the clickDetectors
value to {}
, there is no errors, but the numbers are still there.