I'm trying to make a damage system for a beam remember the players/mobs that got hit by the beam and how much damage is supposed to be dealt to them, but I'm not sure how to use tables/subtables to remember that info.
How do I pull damageCalc from the table? It has to match the hitName it went in there with.
local entityList = {{},{}}
--Damage system is here
local hitName = Part.Parent.Name
--How to pull damageCalc out for the specific hitName???
if game.Players:GetPlayerFromCharacter(Part.Parent) and (entityList[hitName]) then
Part.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(entityList[damageCalc])
end
--Inserting entity into table if not found
if game.Players:GetPlayerFromCharacter(Part.Parent) and not (entityList[hitName]) then
table.insert(entityList {hitName, damageCalc})
end

3 comments
It's nice that you grouped the code, but there's an actual code block that you can place that in that shows line numbers. It would be helpful in order for us to easily explain to you. Also your code is cut off, so I can't see it all.
Also do you have damageCalc as a function or a variable? Can you show that as well? Because right now, I can't help you because I don't know what that is.
http://xyproblem.info