You are not adding the object to the table correctly, in this line:
table.insert(objects, object)
-- you are adding it to the end of table
-- so it would be an array not a dictionary
What you should do is make the object be the key and create a table for holding the players:
objects[object] = {}
Also, if you’re doing this then you need to detect when the object gets destroyed and remove it from the table, if you don’t then you would leak memory:
object.AncestryChanged:Connect(function()
if (not object:IsDescendantOf(game)) then
objects[object] = nil -- setting it to nil removes it from the table
end
end)
If you want to learn more about memory leaks you can read this : Garbage Collection and Memory Leaks in Roblox - What you should know
Also, there is another problem with how you are adding players to the table, if you want it to have to format you described. Its the same thing you did for the objects table:
table.insert(objects[object], modelsHit[player]) -- this line
--should be:
objects[object][player] = true