Is it possible to get a shape’s width or length through scripting?
if yes how can I do it?
I’m still a beginner at scripting…
, thanks!
Depends on in what direction you want to measure.
If you just want to measure on the XYZ axis doing .Size.XYorZ
should be enough.
Otherwise you can put it inside a model and call :GetExtentsSize()
on it, I think you can choose an angle by setting the primary part of the model and rotating it in the desired direction.
oh thanks for the info I’m going to try that right noww
it actually work thx. I’ll search more about the [ :GetExtentsSize()
] tysm
You can use the MeshPart.Mesh object and the Mesh.Geometry property to determine the length of any shape. Here’s an example of measuring the length of a Part object tho remember this also works on mesh parts.
local part = game.Workspace:FindFirstChild("Part")
if part and part:IsA("Part") then
local mesh = part.Mesh
if mesh then
local geometry = mesh.Geometry
if geometry then
local length = 0
for i, vertex in pairs(geometry) do
if i > 1 then
length = length + (vertex - geometry[i-1]).Magnitude
end
end
print(length) -- Output: The length of the shape
end
end
end
MeshParts don’t have a .Mesh
property.
Also if it did, your code would measure the total distance between vertices in order, not the length.
(the orange lines instead of the blue line)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.