How to do "value < x < value" in a "if then" statement?

I’m trying to do “if magnitude is between two numbers” in an if then statement, but it doesn’t work. It will error attempt to compare number and boolean. Any other ways?

Tried:
if 10 > ((Char.PrimaryPart.Position-ClosestTarget.RootPart.Position).Magnitude) > 20 then
or
if not ((Char.PrimaryPart.Position-ClosestTarget.RootPart.Position).Magnitude) < 10 and not ((Char.PrimaryPart.Position-ClosestTarget.RootPart.Position).Magnitude) > 20 then
or

local AmbushMagnitude = NumberRange.new(10,20)
if ((Char.PrimaryPart.Position-ClosestTarget.RootPart.Position).Magnitude) == AmbushMagnitude then

Just use and. This isn’t Python.

value < x and x < value

2 Likes