What I am saying is that there is a frame called inventory with slots for items inside. The amount of slots changes depending on what the player has in the inventory. I am trying to make it so a script runs through all the slots to see if they are being clicked, even if the amount of slots changes. It is working fine; except that the output displays the ilist[i].Label.Text a lot of times, like 160 times the first click and 2000 the next. I know why the thing is not working (because the called function stacks) . I just don't know how to fix it, I have zero idea. Help.
Script:
local rs = game:GetService("RunService")
local debtable = {}
rs.Heartbeat:Connect(function()
ilist = script.Parent.HOLDER.Inventory:GetChildren()
for x = 1, #debtable do
if debtable[x] then
debtable[x]:Disconnect()
end
end
for i = 1, #ilist do
local bruh
if ilist[i] then
bruh = ilist[i].Label.MouseButton1Click:Connect(function()
print(ilist[i].Label.Text)
debtable[#debtable+1] = bruh
end)
end
end
end)
The rest of the script is just functions responding to BindableEvents, and works perfectly well. Thanks.
