Com
Key RequiredUniversal

Com

Universal ScriptPoopy_1Poopy_1 560 views 103 executesUpdated Dec 26, 2025
Unrated
00
Lua Script•41 lines (958 chars)
local model = script.Parent
local RunService = game:GetService("RunService")

-- Create the visual marker
local marker = Instance.new("Part")
marker.Shape = Enum.PartType.Ball
marker.Size = Vector3.new(0.6, 0.6, 0.6)
marker.Material = Enum.Material.Neon
marker.Color = Color3.fromRGB(255, 0, 0)
marker.Anchored = true
marker.CanCollide = false
marker.Name = "CenterOfMassMarker"
marker.Parent = workspace

-- Function to calculate true center of mass
local function getCenterOfMass()
	local totalMass = 0
	local weightedPosition = Vector3.zero

	for _, part in ipairs(model:GetDescendants()) do
		if part:IsA("BasePart") then
			local mass = part:GetMass()
			totalMass += mass
			weightedPosition += part.Position * mass
		end
	end

	if totalMass == 0 then
		return nil
	end

	return weightedPosition / totalMass
end

-- Update every frame
RunService.Heartbeat:Connect(function()
	local com = getCenterOfMass()
	if com then
		marker.Position = com
	end
end)

Features & Information

Com offset

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts