How do I get the radius and height of an existing cylinder?

This might sound like a stupid question but I seriously have no idea how to get the radius and height of a cylinder. I’m trying to fill with air with a specific cylinder size/rotation inside of water, with Terrain.FillCylinder:. I can get the CFrame of the cylinder, but not the radius since there’s no such command as "print:(workspace.Cylinder.Radius)" How can I find those numbers?

Full code:

workspace.Terrain:FillCylinder(workspace.CylinderWaterClear1.CFrame, -, -, Enum.Material.Water) --P.S. ignore the "-", I put that because I don't know the number to put instead.

If it is a part get the smaller size in either the z or the y:

getRadius = function(part)
    return (part.Size.Z<part.Size.Y and part.Size.Z or part.Size.Y)/2
    --[[In the above we are returning the smallest, first we check if Z is smaller
    than Y, if so then we return Z or else we return Y.]]
end;

Height is the size X.

getHeight = function(part) return part.Size.X end;
3 Likes

Also, the reason we get the smallest is that this:
image
Is not the size of the actual cylinder

2 Likes

Where to put the part’s location/name exactly (such as workspace.Cylinder)? And how do I make it print the result number in output? (I’m a bit new to scripting, sorry)

Call the function.

print("The radius is", getRadius(workspace.Cylinder));
print("The height is", getHeight(workspace.Cylinder));
1 Like

Nvm, I found it. Simply put;

local part = workspace.CylinderWaterClear1 print((part.Size.Z<part.Size.Y and part.Size.Z or part.Size.Y)/2)

Thanks for the explanation!

1 Like

Well yes, but if you want you can use the function to reduce the times you call that formula.

local radius1 = (part.Size.Z<part.Size.Y and part.Size.Z or part.Size.Y)/2
local radius2 = (part2.Size.Z<part2.Size.Y and part2.Size.Z or part2.Size.Y)/2
local radius3 = (part3.Size.Z<part3.Size.Y and part3.Size.Z or part3.Size.Y)/2

Is more messy than:

getRadius = function(part)
    return (part.Size.Z<part.Size.Y and part.Size.Z or part.Size.Y)/2
end;

getHeight = function(part) return part.Size.X end;

local radius1 = getRadius(part);
local radius2 = getRadius(part2);
local radius3 = getRadius(part3);
2 Likes