Once again having troubles with putting values into tables. This time it is an item that is going to be put in a table so that I can keep track of how many parts there are in there. Here is what I have:
bags = {}
trunk.Touched:connect(function(hit)
if hit.Name == "MoneyBag" then
local moneybag = hit
print("yes")
if moneybag then
local money = moneybag:FindFirstChild("Money").Value
print("funker")
for _, moneybag in pairs(bags) do
print("japp")
if moneybag ~= bags then
table.insert(bags, moneybag)
totalmoney = totalmoney + money
print("no")
end
end
end
end
end)
Forgot to add the table in the first version, but there it is.
Thank you for your help (:

4 comments
Where is your Table at? Also, I wouldn't use moneybag as a variable in line 7 because it is assigned something. You should have your Table already existing at first for this script.
What is 'bags'? I don't see any Variable named 'bags' anywhere, other than it being used in and inside the 'for' loop code block chunk, unless this is not the full script, and if that's the case, please include the FULL script/code.
There's no point in using
:FindFirstChildif you're going to go ahead and use.on it anyway.You didn't define bags in the script.