Does anyone know a good way to convert this to a Vector3?
1 Like
You could create a pattern for use with string.match
:
local pattern = "<Vector3> %((.-), (.-), (.-)%)"
local function convert(s)
local x, y, z = s:match(pattern)
return Vector3.new(
assert(tonumber(x), x),
assert(tonumber(y), y),
assert(assert(number(z), z)
)
end
Note that tonumber
returns nil if the value doesn’t convert. Passing nil
to Vector3.new
is interpreted as 0, so I wrap it in assert
to ensure the value was converted.
2 Likes
i know, i am extremely late. But the number in line 7 is an unknown global. Should i worry?