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

How can I compare vector3 values?

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

✓ Accepted answer

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.

1 comment

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.

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