it says attempt to compare two userdata values
** if game.Workspace.Baseplate.Size >= Vector3.new(251,20,251) then** x = math.random(-255, 255) y = math.random(6, 30) z = math.random (-255, 255) end
The if - then is where the error occurs
it says attempt to compare two userdata values
** if game.Workspace.Baseplate.Size >= Vector3.new(251,20,251) then** x = math.random(-255, 255) y = math.random(6, 30) z = math.random (-255, 255) end
The if - then is where the error occurs
You can't compare Vector3's to see if they're less than or more than. Instead, compare their components.
function compare(x, y)
if x.X >= y.X and x.Y >= y.Y and x.Z >= y.Z then
return true
end
return false
end
if compare(workspace.Basplate.Size, Vector3.new(251, 20, 251)) then
x, y, z = math.random(-255, 255), math.random(6, 30), math.random(-255, 255)
end
It works but could you explain it a lil cuz im new to this stuff
The function 'compare' has two parameters: 'x' and 'y', which we will use to compare Vector3's when we pass them as arguments in the if statement. The function will check if all values of 'x' are more than the values of 'y'. If they are, then we will return true, else it will return false. In the if statement, we're going to pass two arguments which are Vector3's. If it's true, then we will procee
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
please use code blox
Can't compare them straight up like that. Try getting the scalar values (e.g. Baseplate.Size.x > 251)