Skip to content

Instantly share code, notes, and snippets.

@devSparkle
Created August 26, 2022 11:02
Show Gist options
  • Save devSparkle/5a59d769a1dcf9e8d57f98ab768da0bc to your computer and use it in GitHub Desktop.
Save devSparkle/5a59d769a1dcf9e8d57f98ab768da0bc to your computer and use it in GitHub Desktop.
Calculate Polygon Center
for _, Polygon: Model in next, game.Selection:Get() do
if not Polygon:IsA("Model") then continue end
local Center = Vector3.zero
local Children = Polygon:GetChildren()
for _, Child: BasePart in next, Children do
if not Child:IsA("BasePart") then continue end
Center += Child.Position
end
Center /= #Children
Polygon.WorldPivot = (Polygon.WorldPivot - Polygon.WorldPivot.Position) + Center
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment