-- Ensure hat is attached to head initially hat.Handle.CFrame = head.CFrame * CFrame.new(0, heightOffset, 0)

-- Apply position via BodyPosition (Replicated to all clients automatically) orbitData.bodyPosition.Position = targetPosition end)

-- Cleanup when player leaves game.Players.PlayerRemoving:Connect(function(player) if activeOrbits[player.UserId] then local data = activeOrbits[player.UserId] if data.heartbeatConnection then data.heartbeatConnection:Disconnect() end activeOrbits[player.UserId] = nil end end)

For production use, wrap the orbit logic in a ModuleScript:

-- Reconnect when character respawns player.CharacterAdded:Connect(function(newChar) character = newChar head = character:WaitForChild("Head") lastUpdate = os.clock() end)