Trying to get BOTH values when I loop through a dictionary

I want to sue an for i,v in pairs loop on a dictionary but I want both of the values.
For example my dictionary is this:
local dictionary = {
GamerGod1000 = 100
}
and when I loop through it like this
for i,v in pairs(dictionary) do

end

I want to get the “GamerGod1000” and its value which is = 100. How do I do that?

The i is the index and the v is the value

for i,v in pairs(dictionary) do
  print(i) --  GamerGod1000
  print(v) -- 100
end
1 Like

i = “GamerGod1000”
v = 100

Unless I am missing something here.

I tried that and I am getting weird values. Maybe it has something to do with my script that actually sets the data of the module script. Here is it:
local event = game.ReplicatedStorage.RemoteEvent

local damageCollection = require(game.ReplicatedStorage.DamageCollection)
local player = rayCastResults.Instance.Parent
local plrName = player.Name
table.insert(damageCollection,player.Name)
if damageCollection.plrName == nil then
damageCollection.plrName = 0
end
damageCollection.plrName += 10

What are the results your getting?

This part is indexing the string “plrName” not its value.

damageCollection.plrName

Try changing to:

damageCollection[plrName]