Is it better to do Hit[Character] = true or table.insert(Hit, Character)

Like I am trying to check if somebody got hit

Is first or second better? Because then I will do one of these:

if Hit[Character] then
    -- ...
end

or

if table.find(Hit, Character) then
    -- ...
end

the first approach is more efficient in terms of lookup time because it’s a direct key-value check. table.find is slower because it involves iterating through the entire table until it finds a match, which isn’t ideal if ur using larger tables

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.