Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a way of efficiently comparing values?

Example:

I have 4 IntValues.

The first IntValue has a value of 1.

The second IntValue has a value of 3.

The third IntValue has a value of 4.

The fourth IntValue has a value of 2.

What is the most efficient way of finding the one with the highest value? What happens if two IntValues have the same Value?

1 answer

✓ Accepted answer

You can do the following:

local val1 = 1
local val2 = 4
local val3 = 3
local val4 = 4
local biggest = {}

if val1 >= val2 then
	if val1 == val2 then
		biggest[1] = 'val1'
		biggest[2] = 'val2'
	else
		biggest[1] = 'val1'
elseif val2 > val1 then
	biggest[1] = 'val2'
end

and etc. I didn't bother to make a long, completed code for you, as you didn't provide code to what you tried.

1 comment

0

Thanks! I've completed the code!

This discussion is preserved as it was. New answers, comments, and votes are closed.