Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I compare vector3 values?

Asked by 6 years ago
Edited 6 years ago

For example

part.Size = Vector3.new(1,1,1)
if part.Size >= Vector3.new(4,4,4) then

keep getting "Attempt to compare two userdata values" error.

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

This will work. *TESTED*

part.Size = Vector3.new(1,1,1) -- doot!
if part.Size.X >= 4 and part.Size.Y >= 4 and part.Size.Z >= 4 then -- compare all 3 of the values in the Vector3 that you popped in to the number 4, no errors inclooded

If this does not work, it is because I used a table to test the code. This is the precise code I used to test it:

local part = {
    Size = "derp"
}
part.Size = Vector3.new(1,1,1)
if part.Size.X >= 4 and part.Size.Y >= 4 and part.Size.Z >= 4 then
    print("burp") -- don't laugh plz
else
    print("ayy")
end

And if so, please comment on this.

0
That works yes. And lets say you wanted to do total volume, you would multiply X,Y,Z and compare those two values. Not sure what you would want to do that for, but eh. TiredMelon 405 — 6y
Ad

Answer this question