Any easy way to compare vectors to numbers?

trying to check if a parts velocity is over a amount in any vector (x, y or z) and the way i normally do it is just a long if statement with alot of ors

maybe look at Vector3.magnitude? (https://developer.roblox.com/en-us/articles/Magnitude)

There isn’t much you can do about that but you can make a function that handles that so you only have to write it once or you can use the math.max function and then compare the result to the number. Something like this:

local Vector = Vector3.new() --The vector3 you want to compare
local Max = --the amount

if math.max(Vector.X, Vector.Y, Vector.Z) > Max then
 --Do magic
end

2 Likes

That wouldn’t really work for this since they’re trying to determine if any of vector’s component is greater than a value

yeah, might have to just do this