Requesting Some Lua help

I’m fairly novice when it comes to lua, really trying to get out of my comfort zone. As of now I was giving a command (coded under server) that could set a players health. I could probably do it were it not for me having no clue how to use the

for k, v in pairs

I’ve no clue what to do with it or where to put it so I thought I’d put this account I made a while back to good use

here’s the code I have so far.
Like I said, novice, be gentle lmao

function SetHealthCommand(ply, text, team)
local Argument = string.Explode(" ", text) 
	if (Argument[1] == "!sethealth") then
		if (Argument[2] == text) then
			if (tonumber (Argument[3]) then
				for k, v in pairs (player.GetAll()) do
					v:SetHealth() == Argument[3]
	return ""

hook.Add("PlayerSay" "Command_/sethealth" SetHealthCommand)

edit: Looking at it now it seems I screwed up on argument[2], gonna fix it.

You use it when you’re looping over a table. Whatever is in the pairs’ function parentheses is the table that is going to be looped over.

Every value in a table has a key associated with it. k and v are short for key and value. In this loop, the key will be k and the value will be v.

for blah, blahblah in pairs is the same as for k, v in pairs. They are just variable names. You can name them something else if you wish.

If you have a table like this, for example
local tab = {
[“key”] = “value”

for k, v in pairs(tab) do
print(k, v)
k will be “key” and v will be “value”