✓ Accepted answer
You cannot use table.concat() to get objects from a table and make a touched event out of it. First, I will tell you what table.concat() does. This will get your table, which is the first argument, and with everything in it, put it as a string with whatever you want to space each out. All things must either be a string or number. So, if your table was just Table = {"The", "Cat"} and you printed table.concat(Table, "SPACE"), then the output will be "TheSPACECat because you chose SPACE to be in between each, if you're confused you can view the wiki (Which I think is more confusing about this topic) here for table.concat()
Now, I will ASSUME that your tables contents are all objects and you have a variable somewhere that give the object, example, local LSeg1 = game.Workspace.LSeg1, and so on.
Now that your Table is all object, we can Iterate through this table using a generic for loop and connect them all to a touched event. Please look at some commenting for some more information on what I'm doing! Also, you may want to work on tabing your code correctly, if you don't know how, just comment.
ID1Parts = {LSeg1, LSeg2, LSeg3, LSeg4, LSeg5}
debounce = false
for _, aPartInTable in pairs(ID1Parts) do
aPartInTable.Touched:connect(function(part)
local Human = part.Parent:FindFirstChild("Humanoid")
if Human and not debounce then
debounce = true
Human:TakeDamage(10)
end
end)
end
If this helped, accept the answer and if you have questions, just comment on this answer!
2 comments
Is it just me, or does the way this is tabbed out annoy you?
Thanks for the great answer, helped alot!