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

how to know if a player's numbervalue has a value below 10?

I'm not sure how to make the title different but here is the question:

player1 has a number value of 10, player2 has a number value of 6.

i want to see if player2's number value is near player1's value by 3.

So if the values are below and is the same as and above 7 and below 10 then it would return true

any idea how to do this??

thanks

2 comments

1

you mean if player 1's value is 10 player 2's value can be 7 8 9 10 11 12 13 to return true?

0

yup

1 answer

✓ Accepted answer

Suppose the two numbers are A and B.

You want to know if A and B are within 3 of each other. In other words, B - A should be at most 3, and A - B should be at most 3.

if A - B <= 3 and B - A <= 3 then
	-- they're within 3

You can also write this using math.abs, since the larger of B - A and A - B is just math.abs(A - B):

if math.abs(A - B) <= 3 then
	-- they're within 3

1 comment

0

wth are you like the grandfather of lua or something ? how do you even know all that stuff? hahahhaha thanks :)

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