How do I get more than one persons name in a script?

I am trying to create a report system where if a player shoots a player, the player that has been shot can shoot them back without getting wanted and report them. But I have a problem, I am using a string value, and what if more than one person shoots at the player. How would I get more than one player name? Any other way to do this?

-- This is an example Lua code block

if Tagger and TargetHumanoid and TargetHumanoid.Health ~= 0 and TargetTorso and DamageModule.CanDamage(TargetHumanoid.Parent, Tagger) then --shoots player

if TargetHumanoid.atkr.Value ~= Player.Name and Player.Character.Humanoid.atkr.Value ~= TargetHumanoid.Parent  then --if player shot first then
				TargetHumanoid.atkr.Value = Player.Name --player can use this to report
				print("hit")
			end 
1 Like

If you create a value everytime the player is hit, you could try this:

local players = { } -- table to hold the names

for _, v in pairs(TargetHumanoid:GetChildren()) do
   if v.Name == "atkr" and v:IsA("StringValue") then
      table.insert(players, v.Value) -- add the player to the table
   end
end

-- now the 'players' table is filled with the players name
1 Like

How would I check for a players name?

local players = {“John”,“Jane”,“Jack:” }

How would I find if Jane’s name is in the table?

and can tables data be sent from client to server?

if table.find(players, "Jane") then
  -- do stuff
end

Yes

1 Like