Attempt to compare Vector3 < boolean

elseif not Creature:GetExtentsSize() > Vector3.new(20,20,20) then error("Too big")

GetExtensSize returns a Vector3, i dont see an error here

If I remember correctly, not takes priority over everything else, so you would have to change it to:

elseif not (Creature:GetExtentsSize() > Vector3.new(20,20,20)) then error("Too big")
1 Like

Ok that helped but now the error is Attempt to compare Vector3 < Vector3

You can’t compare a Boolean and a Vector

I know… :shallow_pan_of_food:

You said GetExtentsSize returns a Boolean, so you can’t compare that to the Vector3.new(20,20,20)

1 Like

You will have to compare each component of the vector individually
Messy but probably working code:

local ExtentsSize = Creature:GetExtentsSize()
local MAX_SIZE = Vector3.new(20, 20, 20)
--if statements here
elseif not (ExtentsSize.X > MAX_SIZE.X and ExtentsSize.Y > MAX_SIZE.Y and ExtentsSize.Z > MAX_SIZE.Z) then error("Too big")

Oops :flushed:
GetExtentsSize returns a vector3

2 Likes

Yeah i guess this works, weird how you can perform arithmethics on a vector3 but not use them in if statements.

You could use Vector3.Magnitude, and compare it to the magnitude of the other vector.

Note that this is different from comparing the x to x, y to y, etc . It depends on what you want to do, which is also the reason vector3>vector3 doesn’t work: its not very clear what should exactly happen in that case.

And indeed, I always put extra brackets around my logic components to make it extra extra clear what has priority. :slight_smile:

1 Like