How to compare multiple values

I made a script that creates a number value and that value increases by when a player kills a player. Now what I’m trying to do is compare the values from each player in the game. How can I do this? Do I need a table or something?

1 Like

Yes, you’d have to do this. As well as that, could you show us the script you used?

local plrs = {}

	local plrs = {}

	for i, player in pairs(game.Players:GetPlayers()) do
		if player then
			table.insert(plrs,player) -- Add each player into plrs table
		end
	end

	for i, player in pairs(plrs) do
		if player then
			table.insert(plrs,player) -- Add each player into plrs table
			character = player.Character
			KOCount = Instance.new("NumberValue")
			KOCount.Parent = character
			KOCount.Name = KOCount
		end
	end

Instead I’d change the table insert to:

table.insert(plrs,player,KOCount)
-- If I am right this could fail, so instead I suggest:
-- Adding an array for every player,
-- Inserting the player's object inside of the array,
-- Inserting the KOCount.Value inside of the array as well.

then detect if the value of KOCount changed;

KOCount:GetPropertyChangedSignal("BrickColor"):Connect(function(Property)
    plrs.player = KOCount
end)