Can you convert a Vector3 value into a single value?

I want to know if there is a built-in function that allows you to convert a vector3 value into a single digit.

1 Like

Magnitude? Something like Vector3.new(10, 10, 10).magnitude → Returns the length of the vector. (A single value)

2 Likes

Your question is not so clear, If you are talking about making Vector3.new(10,10,10) become a single digit, well, then it would be a pretty useless thing but you can do Vector3.new(10,10,10).Magnitude.

If you are seeking to get the distance between 2 points you can do Vector3.new(10,10,10) - Vector3.new(11,11,11).Magnitude.

(Note that the numbers are just example.)

2 Likes

No, you cannot convert a Vector3 value into a single number, because a Vector3 contains three numbers(you can’t really fit three numbers into one).

If you want to retrieve the X, Y or Z of a Vector3, you can simply do the following:

local v3 = Vector3.new(10, 10, 10)

print(v3.X) -- returns the x
print(v3.Y) -- returns the y
print(v3.Z) -- returns the z

Hope this helped.

3 Likes

No, I don’t think you can do that, it needs three numbers to work make a vector3 thing. But you can turn it into a variable like:

local vector3value = Vector3.new(1,1,1)
1 Like

using .Magnitude on a vector will return the length of the vector as a single value.

e.g.

Vector3.new(0,5,0).Magnitude --> returns 5

2 Likes